Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateusfreira/nun-db-js
https://github.com/mateusfreira/nun-db-js
hacktoberfest javascript nodejs
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mateusfreira/nun-db-js
- Owner: mateusfreira
- Created: 2019-09-30T21:15:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T18:37:17.000Z (8 months ago)
- Last Synced: 2024-05-01T23:56:56.352Z (6 months ago)
- Topics: hacktoberfest, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 1.07 MB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nun-db JS
Nun-db js library for web and Node
## Instalation
```
npm install --save nun-db```
## Simple usage get set
```javascript
//import nundb
const NunDb = require('nun-db');//Connect to the database using db main token
//const db = new NunDb('wss://ws.nundb.org/', 'db-name', 'db-token');//Connect to the database limited user
const db = new NunDb({ url: 'wss://ws.nundb.org/', db: 'db-name', user: 'user-name', token: 'db-token' });db.setValue('someKey', 'someValue');
db.set('someKey', 'someValue');//Alias to setValue// get a key
db.getValue('someKey').then( value => {
console.log(`Here is the key value: ${value}`);
// Here is the key value: someValue
});```
## Watch
```javascript
//import nundb
const NunDb = require('nun-db');//Connect to the databse
const db = new NunDb('wss://ws.nundb.org/', 'db-name', 'db-token');// get a key
db.watch('someKey', value => {
console.log(`Here is the key value: ${value}`);
// Here is the key value: someValue
// Here is the key value: someValue1
});
db.setValue('someKey', 'someValue');
db.setValue('someKey', 'someValue1');```