【日本語 / English】
DB module in JSON format created with Deno.
Deno is supported Node.js and npm packages.
This module was inspired NeDB. Simple control like NeDB and all datastore unified API control. That was goal. But it was out of reach.
This project is freezed.
This module does not support encryption. Do not use it to store important data.
- Deno Modules
- Save in JSON format
- The storage formats are in-memory and file
Support for Local Storage API and Cache API is planned.
See Issues for more information.
If you don't see a feature you think you need, please create an Issue and let me know. You will use it as a reference.
There are two main types: file creation and in-memory.
The file creation format has a separate module as FileDB
, because Deno Deploy cannot create files due to its specification. The others are modularized as BracesDB
.
Since FileDB
reads and writes files, please add --allow-read
and --allow-write
when executing.
type
is the DB type. Currently, only in-memory can be specified.
import { BracesDB } from "https://deno.land/x/bracesdb/mod.ts";
interface DB {
name?: string;
description?: string;
}
const db = new BracesDB<DB>({ type: "memory" });
folder
is the DB path. Default path is project root.
filename
is the DB name. Default name is main
.
import { BracesDB } from "https://deno.land/x/bracesdb/mod.ts";
interface DB {
name?: string;
description?: string;
}
const db = new BracesDB<DB>({
folder: "./db/",
filename: "test",
});
The first argument is the Object to add to the DB.
The second argument is the key used in the duplication prevention process.
const test = {
name: "Toika Asomaka",
description: "A name that just popped into my head",
};
await db.add(test, "name");
The first argument is the key, and the second argument is the value of the key.
await db.delete("name", "Toika Asomaka");
Perfect match and partial match supported.
Returns an Object that matches the conditions, with the name of the key as the first argument and the value of the key as the second argument.
No arguments return all DB data.
// Perfect match
const data = db.find("name", "Toika Asomaka");
// Partial match
const dataPartial = db.find("name", /Toika/);
// All DB data
const dataAll = db.find();
Execute the following command.
$ git clone https://github.com/rwl-dev/bracesdb.git
$ cd bracesdb
$ deno task test
I am using "DeepL Translation" to translate this README.