NeDB-based database hosted on Discord
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
KaKi87 d5bb10e695 🔧 📝 As per 8d0c22a 1 month ago
.gitignore 🎉 Initial commit 1 month ago
README.md 🔧 📝 As per 8d0c22a 1 month ago
index.js 🐛 Fix user channel fetching 1 month ago
package.json 🔧 📝 As per 8d0c22a 1 month ago
yarn.lock ♻️ Replace 'nedb' dependency by 'nedb-promises' 1 month ago

README.md

Discord NeDB

NeDB-based database hosted on Discord.

Installation

From npm :

  • yarn add discord-nedb

or

  • npm install discord-nedb

Built with

Usage

Initialization

const Datastore = require('discord-nedb');

const database = new Datastore(
    'token',
    'guildId',
    'channelId',
    'userId',
    'messageId'
);

const messageId = await database.loadDatabase();
  • The token parameter is a required bot token
  • Either provide guildId + channelId or userId
  • When messageId is undefined, a new message will be created
  • Always call loadDatabase, which will return messageId, especially useful at first initialization

Data manimulation

Methods provided by nedb-promises (check Datastore docs) :

Read

  • find
  • findOne
  • count

Write

  • update
  • remove
  • ensureIndex
  • removeIndex

Database compaction

await database.persistence.compactDatafile();

Database compaction is automatically called when the message exceeds Discord's maximum limit.

If compaction doesn't free enough space for additional data, an error will be thrown.

Database deletion

await database.deleteDatabase(
    isDeletingLocally,
    isDeletingRemotely
)
  • When isDeletingLocally is true (default), the local database file is deleted.
  • When isDeletingRemotely is true (not default), the Discord message is deleted.

Changelog

  • 0.1.0 (2020-12-17) • Initial release

License

This project is released under the MIT license.