Skip to main content
Module

x/aloedb/mod.ts>Database

Light, Embeddable, NoSQL database for Deno 🦕
Latest
class Database
import { Database } from "https://deno.land/x/aloedb@0.9.0/mod.ts";

AloeDB 🌿

Light, Embeddable, NoSQL database for Deno

Deno | Github

Constructors

new
Database(config?: Partial<DatabaseConfig> | string)

Create database collection to store documents.

Type Parameters

optional
Schema extends Acceptable<Schema> = Document

Properties

private
readonly
config: DatabaseConfig

Database configuration.

private
readonly
optional
writer: Writer

Data writing manager.

documents: Schema[]

In-Memory documents storage.

WARNING: It is better not to modify these documents manually, as the changes will not pass the necessary checks. However, if you modify storage manualy, call the method await db.save() to save your changes.

Methods

count(query?: Query<Schema> | QueryFunction<Schema>): Promise<number>

Count found documents.

Deletes all documents that matches the search query.

deleteOne(query?: Query<Schema> | QueryFunction<Schema>): Promise<Schema | null>

Deletes first found document that matches the search query.

drop(): Promise<void>

Delete all documents.

findMany(query?: Query<Schema> | QueryFunction<Schema>): Promise<Schema[]>

Find multiple documents by search query.

findOne(query?: Query<Schema> | QueryFunction<Schema>): Promise<Schema | null>

Find document by search query.

insertMany(documents: Schema[]): Promise<Schema[]>

Inserts multiple documents.

insertOne(document: Schema): Promise<Schema>

Insert a document.

load(): Promise<void>

Load data from storage file.

loadSync(): void

Synchronously load data from storage file.

save(): Promise<void>

Write documents to the database storage file. Called automatically after each insert, update or delete operation. (Only if autosave mode enabled)

Modifies all documents that match search query.

Modifies an existing document that match search query.