docmenager
v3.0.3
Published
a local documents menager
Downloads
10
Maintainers
Readme
Installation
npm i docMenager
Example Usage
Initialize:
const DataBase = require("docmenager");
var data = new DataBase("./*path*/");
async function main() {
await data.init();
}
main()
createDoc()
async function main() {
await createDoc({ mainText: "hello world", id: "doc1" }) //creates a new document with 2 properties
}
main() //calls an async function (THE MODULE createDoc() MUST BE AWAITED)
findOne() and updateOne()
async function main() {
await findOne({ //searches for the document that has the property id "doc1"
id: "doc1"
})
.then(() => { //executes after searching the document
await updateOne({ //updates a document that has the property id "doc1"
id: "doc1"
}, {
mainText: "just hello" //replaces the text in mainText
secondaryText: "goodbye world"
}, {
newItem: false, //doesn't allow the method to add any property or create any new documents: secondaryText won't be displayed
newDoc: false
})
.then(doc => { //executes after updating
console.log(doc)
})
})
}
main() //calls an async function (BOTH MODULES findOne() AND updateOne() MUST BE AWAITED)
deleteDoc()
async function main() {
await deleteDoc({ //deletes the document that has id "doc1"
id: "doc1"
})
}
main()