Tuesday 23 May 2017

[Express] How do you save a document to a database efficiently?

Say I want to save multiple documents into the database;I feel like it would be inefficient if I change the placeDoc's attributes and restart the server every time I make a change.Am I doing it incorrectly? is there a much more easier and efficient way?var PlaceSchema = new Schema({ lng:Number, lat:Number }); var Place = mongoose.model("Place", PlaceSchema); module.exports.Place = Place; var placeDoc = new Place(){ lng: "333"; lat: "222"; } placeDoc.save().then(place => { return place.name; db.close(); });

Submitted May 23, 2017 at 11:12PM by badboyzpwns

No comments:

Post a Comment