docmenager
Version:
a local documents menager
59 lines (53 loc) • 1.86 kB
Markdown
```sh-session
npm i docMenager
```
```javascript
const DataBase = require("docmenager");
var data = new DataBase("./*path*/");
async function main() {
await data.init();
}
main()
```
```javascript
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)
```
```javascript
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)
```
```javascript
async function main() {
await deleteDoc({ //deletes the document that has id "doc1"
id: "doc1"
})
}
main()
```