Search Posts

Category: mongodb

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: […]

how to save image to folder and save imagePaths to database in MEAN stack using Multer

I have a image collection of following schema: { “productId”: {type: String}, “imagePaths”: {type: Array} } I want to upload multiple images and store corresponding image-paths to database. I searched, and came to know that Multer can perform this action, but I am unable to upload and save image-paths for multiple images. I tried with this Angular code, scope.demoMethod = function(){ console.log(‘Method fired.’); var product = $scope.product; $http.post(‘/demo/upload’, $scope.product) .then(function (res) { console.log(‘Form Data ::’ […]

angularjs: getting connection refused from mongodb query

First off, I’m new to angular, mongodb and nodejs. I started developing a simple API to get into a job, but now I just want to finish it for personal learning. It stores locations with their geo coordinates, and I’m trying to query these locations based on min and max distance from the user’s position. However, whenever I try this query, i get connection refused. I’ve been trying to make it work for some days […]