Search Posts

Category: mongoose

How can I include data from another collection in my mongoose object?

I am building an app with mongoDB and NodeJS with an Angular front end. I currently have users creating listings and then other users responding with bids within those listings, but want to include data of those responders. I am having a hard time including that user data in the bid create function and not sure why its not pulling. Here is the listing schema var mongoose = require(“mongoose”); var Schema = mongoose.Schema; var Bid […]

Instead of saving inside array, data is getting stored inside new record [duplicate]

This question already has an answer here: Push items into mongo array via mongoose 1 answer I am uploading images using MEAN stack and Multer module. I am able to retrieve images from the angular, and can even post image-paths to Mongoose collection. The problem is I am expecting an array of images but while posting to mongoose, it’s storing each image as a new record. Image schema var imageSchema=new Schema({ productId:{type: String,required: false}, imagePaths: […]

Accesing field outside of callback gives undefined in angular

I have a problem my data structure looks as follows: var mongoose = require(‘mongoose’); var Schema = mongoose.Schema; var schema = new Schema({ name: {type:String, required:true}, domain: {type:String, required:true}, kingdom: {type:String, required:true}, description: {type:String, required:true}, usages:[ {type : mongoose.Schema.ObjectId, ref : ‘Usage’} ], }); module.exports = mongoose.model(‘Flower’,schema,’flowers’); In database usages looks as follows: “usages”: [ { “$oid”: “59785b0c267c14036038324b” } ], after i populate page with data from http get: var app = angular.module(“flowerDataApp”, []); app.controller(‘dataPopulateController’, […]