Modal
The primary interaction point for handing schemas and documents.
info
See examples/databasing for getting started with databasing.
Constructor
new Modal(name, schema, scoreboardName);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
name | string | ❌ | undefined | Name of model (used to reference serialized data for fetching). |
schema | Schema | ❌ | undefined | Blueprint for modal. |
scoreboardName | string? | ✔️ | BeAPI__DATABASE | Name of scoreboard documents for this modal should go under. |
Properties
schema READONLY
Parent schema blueprint.
Type: Schema
name READONLY
Schema name used to categorize documents.
Type: Schema
scoreboardName READONLY
Scoreboard name in which schema saves documents to.
Type: Schema
Methods
asArray
Return all documents as an array.
asArray();
Returns
find
Uses partial data provided to find a specific document.
find(partial);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
partial | object | ❌ | undefined | Partial data matcher. |
Returns
findAll
Uses partial data provided to find a all matching documents.
findAll(partial);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
partial | object | ❌ | undefined | Partial data matcher. |
Returns
write
Write a new document to be stored.
write(data);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
data | object | ❌ | undefined | Data to be stored. |
Returns
writeBulk
Write a new document to be stored.
write(data);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
data | object[] | ❌ | undefined | Datas to be stored. |
Returns
delete
Deletes documents from database.
delete(id);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
id | string | ❌ | undefined | Document to delete. |
Returns
void
deleteAll
Deletes all documents from database.
warning
This is pretty dangerous and irreversible... Be careful!
deleteAll(data);
Returns
void
sync
Syncs document with persistent storage.
sync(id);
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
id | string | ❌ | undefined | Document to sync. |
Returns
void