New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@tiledesk/tiledesk-kvbasemongo

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiledesk/tiledesk-kvbasemongo

A key-value store adapter for MongoDB

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
4
Created
Source

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.");

FAQs

Package last updated on 21 Jul 2022

Related posts