This module is a simple local json database good for small projects and very simple games
npm install jdbx
const { Database } = require("./jdbx");
const db = new Database(__dirname, "dbName")
A method that must start before other methods That gets the currenct collection
db.collection("NAME")
A method that pushs an object to the collection
db.collection("NAME").insert({
name:"Tom",
age:42,
email:"email@email.com"
})
_prop | datatype | options | description |
---|---|---|---|
_times | Number | _ | Number of times to insert the data |
A method that gets data of a certain condition ---s Conditon get
db.collection("NAME").get({name:"Tom"}, (err, data) => console.log(data))
All get
db.collection("NAME").get({}, (err, data) => console.log(data))
_prop | datatype | options | description |
---|---|---|---|
_type | String | one, all | returns all data or the first index of the data |
_index | Number | _ | returns an index of a entry |
A method that overwrite a existing entry with the to param
Two params (from, to)
db.collection("NAME").update({name:"Tom"}, {name:"Bill"})
A method that Delets an entry, entries, collection
One Entry Remove
db.collection("NAME").remove({name:"Tom"})
All Entries Remove
db.collection("NAME").remove({name:"Tom", _all:true})
Collection remove
db.collection("NAME").remove({_force:true})
_prop | datatype | options | description |
---|---|---|---|
_force | Boolean | _ | Deletes a the collection if set to true |
_all | Boolean | _ | Deletes all entries that match the condition if set to true |