mongooose save code example
Example 1: mongoose model
const schema = new mongoose.Schema({ name: 'string', size: 'string' });
const Tank = mongoose.model('Tank', schema);
Example 2: node mongoose save document
const person = { name: Jane, surname: Doe};
savedPerson = await new Person(person).save()
Example 3: mongoose save a document
const Person = mongoose.model('Person', Schema({
name: String,
rank: String
}));
const doc = new Person({
name: 'Will Riker',
rank: 'Commander'
});
await doc.save();
const person = await Person.findOne();
person.name;