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 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...
I use Mongoose.js and cannot solve problem with 3 level hierarchy document.  There 2 ways to do it.  First - without refs.  C = new Schema({     'title': String, });  B = new Schema({     'title': String,     'c': [C] });  A =...
I'm working with Mongoose. I have seen a lot of developers make the following command:   mongoose.Promise = global.Promise;   Then I was curious to see what is the original value of mongoose.Promise . I have entered in my editor the following com...
Is it possible to insert in Mongo with condition;  //Pseudo code  Bulk Insert Item :  If Key exists     Skip, don't throw error If key does not exist     Add item   If i do single inserts, it might return an error or insert in the collection, but...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.