Doc:  {    _id: 5150a1199fac0e6910000002,    name: 'some name,    items: [{       id: 23,       name: 'item name 23'    },{       id: 24,       name: 'item name 24'    }] }   Is there a way to pull a specific object from an arra...
I want to drop some mongodb collections, but that's an asynchronous task. The code will be:  var mongoose = require('mongoose');  mongoose.connect('mongo://localhost/xxx');  var conn = mongoose.connection;  ['aaa','b...
I'm trying to select only a specific field with  exports.someValue = function(req, res, next) {     //query with mongoose     var query = dbSchemas.SomeValue.find({}).select('name');      query.exec(function (err, someValue) {         i...
I came across a piece of Mongoose code that included a query findOne and then an exec() function.  Ive never seen that method in Javascript before? What does it do exactly?...
To modify a field in an existing entry in mongoose, what is the difference between using  model = new Model([...]) model.field = 'new value'; model.save();   and this  Model.update({[...]}, {$set: {field: 'new value'});   The reason...
I'm trying to dynamically create _id's for my Mongoose models by counting the documents in the db, and using that number to create the _id (assuming the first _id is 0). However, I can't get the _id to set from my values. Here's my...
I have server.js and db.js The db.js file interacts with my database using Mongoose and I use server.js to call functions from db.js :  var mongoose = require('mongoose'); mongoose.connect('', { useNewUrlParser: true }) var Schema =...
I have the following simple shema:   var userSchema = new Schema({     name : String,    age: Number,    _creator: Schema.ObjectId   });    var User = mongoose.model('User',userSchema);   What I want to do is create the new document and ret...
I have a weird issue that is baffling me. I have a model:  var Model = new Schema({     name: String,     variations: Array });   The variations entry looks like this:  [ {code: '', price: '' }, {code: '', price: '' }]...
Trying to implement a Mongoose model in Typescript.  Scouring the Google has revealed only a hybrid approach (combining JS and TS).  How would one go about implementing the User class, on my rather naive approach, without the JS?  Want to be able to...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.