What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-01 17:34:05
not fetch data from mongoose
//All objects add 's' behind => 'student' to 'students' const mongoose = require("mongoose"); const Schema = mongoose.Schema; const StudentSchema = new Schema({ name: String, dob: Date, mobile: String, address: String, }); module... Add solution -
Javascript 2021-09-30 01:47:04
mongoose nested require
var mongoose =require('mongoose'); var Schema = mongoose.Schema; var msg = new Schema({ messageType: String, timestamp: Number, messagestatus: String }); var standardmessage = new Schema({ id: Number, name: String, type: String, message: [... Add solution -
Javascript 2021-09-29 00:35:02
multiple connections to mongoose
var mongoose = require('mongoose') var conn = mongoose.createConnection('mongodb://localhost/db1'); var conn2 = mongoose.createConnection('mongodb://localhost/db2'); var Schema = new mongoose.Schema({}) var model1 = conn.model('User', Schema); var model2 ... Add solution -
Javascript 2021-09-28 05:33:03
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 handl... Add solution -
Javascript 2021-09-25 16:47:02
mongoose geospatial Schema Options
const citySchema = new mongoose.Schema({ name: String, location: { type: { type: String, // Don't do `{ location: { type: String } }` enum: ['Point'], // 'location.type' must be 'Point' required: true }, coordinates: { ... Add solution