1.1.0 • Published 4 years ago
@kiwidb/api-wrapper v1.1.0
Kiwi API wrapper
const kiwi = new KiwiDB("http://api.kiwidb.io/", "APITOKEN");
kiwi.get("Key").then(res => {
console.log(res.value)
})
Installation
With NPM:
npm install @kiwidb/api-wrapper
With yarn:
yarn add @kiwidb/api-wrapper
Usage
Instancing KiwiDB
// url: The api url of the kiwi rest api
// token: the personal token used for accessing the database
const db = new KiwiDB(url, token)
KiwiDB.get(key)
// Use this method to get a value from the database
// key: key of the value you want to get
db.get(key).then(res => console.log(res.value))
console.log(res.value)
will return the value of the key
KiwiDB.set(key, value)
// Use this method to set a value in the database
// key: the key you want to set
// value: the value you want to set the key to
db.set(key, value).then(res => console.log(res.status))
console.log(res.status)
should return a status code 2XX, if not then the key already exists / something bad happened
KiwiDB.delete(key)
// Use this method to delete a value from the database
db.delete('The key you want to delete').then(res => console.log(res.status))
As before, if a value != than 2XX is returned from console.log
the key probably doesn't exist