Insert data

Here's how you insert data into your JSON file

let data = { username: "Vito Corleone", type: "Human" }
db.insert(data)
    .then((d) => {
        // do something else
    })

Simple right? You can also insert multiple objects at once like this

let data = [
    { username: "Tom Hagen", type: "Human", profession: "Lawyer" },
    { username: "Micheal Corleone", type: "Human" },
]

db.insert(data)
    .then((d) => {
        // do something else
    })

You can also specify your own _id. But make sure they're unique!

let data = { _id: 'uniqueId', username: "Charlie" }
db.insert(data)
    .then((d) => {
        // do something else
    })

results matching ""

    No results matching ""