Modifying Data
Declaring Variable
const FlameDB = require("flame.db");
const db = new FlameDB();
Methods
db.create(path, value)
db.set(path, value)
db.update(path, value)
db.push(path, value)
create(path, value)
This will create a new collection and documents.
// Create a new collection -- {balance: 1000, coins: 12000}
db.create("users/566851016910438400", {balance: 1000, coins: 12000})
set(path, value)
Modify the whole document data. This is different than the update
method
// Modify the whole document data -- {balance: 1000, money: 12000}
db.set("users/566851016910438400", {balance: 1000, money: 12000})
update(path, value)
Modify only the specified field in the document data
// Modify only the specified field -- {balance: 2000, money: 12000}
db.update("users/566851016910438400", {balance: 2000})
push(path, value)
Push item into an array inside the document
// Push item into an array -- {balance: 2000, money: 12000, items: ["Laptop"]}
db.push("users/566851016910438400/items", "Laptop")
Last updated
Was this helpful?