3.0.3 • Published 2 years ago

docmenager v3.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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()
3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago