model mongoose
var Tank = mongoose.model('Tank', yourSchema);
var small = new Tank({ size: 'small' });
small.save(function (err) {
if (err) return handleError(err);
// saved!
});
// or
Tank.create({ size: 'small' }, function (err, small) {
if (err) return handleError(err);
// saved!
});
// or, for inserting large batches of documents
Tank.insertMany([{ size: 'small' }], function(err) {
});const modelName = mongoose.model("collectionname", collectionSchema);
//example
const fruitSchma = new mongoose.Schema ({
name: String
});
const Fruit = mongoose.model("Fruit", fruitSchema);mongoose.connect('mongodb://localhost/gettingstarted', {useNewUrlParser: true,useUnifiedTopology: true});
Also in JavaScript:
- operator to return specific data of a mongodb query
- drupal 8 attach js library
- contact form7 404 wp-json feedback
- how to use reduce in javascript
- how to access a database in express
- javascript online test
- file ajax
- encode url javascript
- addEnd Point js
- javascript count element in array
- how to make a 4 dimensional array in JavaScript
- cordova android close app with back button
- javascript remove last charter stings
- sweet alert react
- urlencode jquery
- how to name a javascript variable
- casl react
- jquery example sheetjs
- cache buster in angular application
- node map has value
- vuejs pass all events to child
- function in javascript
- javascript is object
- remove element by class