🧵insertMany()

Example

import { Model, Schema, Types } from 'cherry3';

const schema = Schema({
name: String,
surname: Types.String,
age: Types.Number,
classNumber: Number,
achievements: { type: Array, default: [] },
closeFriends: Object
});

const model = new Model('classList',schema)

(async() => {

var objectData = [
{ 
name:"Vante", 
surname: "Karahanli", 
age: 23, 
classNumber: 1337, 
achievements: [],
closeFriends: { "1": "Ertu" }
},

{ 
name:"Ertu", 
surname: "Karahanli", 
age: 18, 
classNumber: 31, 
achievements: ["ertus-mom"],
closeFriends: { "1": "Vante" }
}

];

var result = await model.insertOne(objectData)
console.log(result)
/*
[
{name:"Vante", surname: "Karahanli", age: 23, classNumber: 1337, achievements: [],closeFriends: { "1": "Ertu" }},
{name:"Ertu", surname: "Karahanli", age: 18, classNumber: 31, achievements: ["ertus-mom"],closeFriends: { "1": "Vante" }}
]
*/

})();

Last updated