@tiledesk/tiledesk-kvbasemongo

1.0.0 • Public • Published

Tiledesk key-value database adapter for MongoDB

This class uses a MongoDB collection as a very simple key-value storage. It only provides basic methods: set(), get(), remove()

Instance and connect

const kvbase_collection = 'kvstore';
MONGODB_URI = 'YOUR MONGODB CONNECTION URI';
const db = new KVBaseMongo(kvbase_collection);
db.connect(MONGODB_URI, () => {
  console.log("KVBaseMongo successfully connected.");
});

Set a value

let content = {
  name: "Andrew"
}
const CONTENT_KEY = 'YOUR CONTENT KEY'
await db.set(CONTENT_KEY, content)
console.log("Content saved")

Get a value

const content = await db.get(CONTENT_KEY);
console.log("Got content:", content)

## Remove a value

await db.remove(CONTENT_KEY);
console.log("Content deleted.");

Readme

Keywords

none

Package Sidebar

Install

npm i @tiledesk/tiledesk-kvbasemongo

Weekly Downloads

85

Version

1.0.0

License

MIT

Unpacked Size

4.03 kB

Total Files

4

Last publish

Collaborators

  • gab95
  • eljohnny
  • andrealeo83
  • nicolan74
  • dariodepa
  • andreasponziello