0.1.0 • Published 5 years ago
discord-nedb v0.1.0
Discord NeDB
NeDB-based database hosted on Discord.
Installation
From npm :
yarn add discord.db
or
npm install discord.db
Built with
discord.js: Discord API wrappernedb-promises: NeDB wrapper with Promises (based onnedb: JS database)
Usage
Initialization
const Datastore = require('discord.db');
const database = new Datastore(
'token',
'guildId',
'channelId',
'userId',
'messageId'
);
const messageId = await database.loadDatabase();- The
tokenparameter is a required bot token - Either provide
guildId+channelIdoruserId - When
messageIdis undefined, a new message will be created - Always call
loadDatabase, which will returnmessageId, especially useful at first initialization
Data manimulation
Methods provided by nedb-promises (check Datastore docs) :
Read
findfindOnecount
Write
updateremoveensureIndexremoveIndex
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.deleteData(
isDeletingLocally,
isDeletingRemotely
)- When
isDeletingLocallyistrue(default), the local database file is deleted. - When
isDeletingRemotelyistrue(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.
0.1.0
5 years ago