All Projects β†’ denyncrawford β†’ dndb

denyncrawford / dndb

Licence: MIT License
A Deno πŸ¦• persistent, embeddable and optimized NoSQL database for JS & TS

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to dndb

AloeDB
Light, Embeddable, NoSQL database for Deno πŸ¦•
Stars: ✭ 111 (+73.44%)
Mutual labels:  nosql, datastore, deno
Nodejs Datastore
Node.js client for Google Cloud Datastore: a highly-scalable NoSQL database for your web and mobile applications.
Stars: ✭ 161 (+151.56%)
Mutual labels:  nosql, datastore
Corfudb
A cluster consistency platform
Stars: ✭ 539 (+742.19%)
Mutual labels:  nosql, datastore
lmdb-js
Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Stars: ✭ 270 (+321.88%)
Mutual labels:  nosql, deno
k2hash
K2HASH - NoSQL Key Value Store(KVS) library
Stars: ✭ 33 (-48.44%)
Mutual labels:  nosql
deno-canvas
Canvas API for Deno, ported from canvaskit-wasm (Skia).
Stars: ✭ 124 (+93.75%)
Mutual labels:  deno
ru102js
Source code for the RU102JS Redis for JavaScript Developers Course
Stars: ✭ 21 (-67.19%)
Mutual labels:  nosql
deno-x-ranking
πŸ¦• Deno Third Party Modules Ranking πŸ‘‘
Stars: ✭ 28 (-56.25%)
Mutual labels:  deno
deno-auth
User authentication implemented in Deno in accordance with MVC architecture
Stars: ✭ 24 (-62.5%)
Mutual labels:  deno
pbkit
protobuf toolkit for typescript and others
Stars: ✭ 173 (+170.31%)
Mutual labels:  deno
drink-if-exists
🍷 The NPM drinking game recreated and cli-ified with Deno
Stars: ✭ 18 (-71.87%)
Mutual labels:  deno
mongodb-atlas-backup
The human way to mongodump and mongorestore your MongoDB Atlas cluster
Stars: ✭ 29 (-54.69%)
Mutual labels:  nosql
pipelinit-cli
Automatically generates pipelines for your project.
Stars: ✭ 36 (-43.75%)
Mutual labels:  deno
deno desktop
Windowing support for Deno WebGPU.
Stars: ✭ 49 (-23.44%)
Mutual labels:  deno
Uwuifier-node
This repository contains the Uwuifier package! It's written in Deno with TypeScript and compiled into JavaScript for NPM, makes use of Jest for testing the code and is deployed on NPM and https://deno.land.
Stars: ✭ 48 (-25%)
Mutual labels:  deno
deno deploy versailles
凑尔衛语录(ιƒ¨η½²εœ¨ Deno Deploy)
Stars: ✭ 18 (-71.87%)
Mutual labels:  deno
deno2node
Compile your Deno project to run on Node.js.
Stars: ✭ 66 (+3.13%)
Mutual labels:  deno
EngineeringTeam
와이빅타 μ—”μ§€λ‹ˆμ–΄λ§νŒ€μ˜ 자료λ₯Ό μ •λ¦¬ν•΄λ‘λŠ” κ³³μž…λ‹ˆλ‹€.
Stars: ✭ 41 (-35.94%)
Mutual labels:  nosql
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-53.12%)
Mutual labels:  nosql
vue-auto-storage
🍻 An automatic storage plugin for Vue2, persist the data with localStorage.
Stars: ✭ 84 (+31.25%)
Mutual labels:  persistent-storage

Deno Logo

nest badge Hits (Deno) license FOSSA Status

A Deno πŸ¦• persistent, embeddable and optimized NoSQL database for JS & TS .
Documentation

Report a Bug Β· Request Feature . Support Us



About DnDB

DnDB is a javascript persistent database written for Deno and available for Typescript.

Inspired by NeDB, DnDB is a robust but minimalist database engine written on JS that uses/emulates the mongo query API to edit and find data, making it 100% exportable to a mongojs environment.

Notice: This project is under development, so it is subject to future improvements and changes.

Why DnDB?

DnDB is an incredibly fast and powerful data store. All methods are streamed and buffered to optimize data reading/writing. DnDB is not only faster, but it consumes less resources (RAM) since only a small portion of the data stream is stored in memory by the buffer, enabling optimal performance on large data collections.

πŸ§ͺ Quick test

Run the demo to test DnDB in a server environment. Also this demo lives on Codesandbox

πŸ“¦ Importing

deno.land

import Datastore from "https://deno.land/x/[email protected]/mod.ts";

nest.land

import Datastore from "https://x.nest.land/[email protected]/mod.ts";

πŸ“– Usage

DnDB works by instantiating collections stored in a specific file given by the user in the instance configuration. By default the created instance exposes the necessary methods to work the datastore.

All the api methods are asynchronous by default, so they return promises, but it's also possible to pass a callback to them to work in a traditional mongo way.

βœ”οΈ Instantiating the collection

import Datastore from "https://deno.land/x/[email protected]/mod.ts";

const db = new Datastore({ filename: "./database.db", autoload: true });

When you instantiate a collection you can pass it a config object with a couple of options:

  • filename: The filename is the absolute path to your target file. If no filename is provided, DnDB will automatically create one in the current working directory, and if a full path is not specified, it will resolve the file name within the CWD.

  • autoload: The autoload option runs the loadDatabase method which creates the persistent file the first time DnDB is running in your project, this is optional, but if the loadDatabase method is not executed, the instance will not work until the persistent file exists.

  • bufSize: The bufSize parameter rewrites the default size of the buffer. It must be indicated in numbers and represents the amount of bytes to be allocated. By default 4096 bytes.

Notice: The configuration content is currently in alpha, more options will be available soon.

πŸ–‹οΈ Inserting documents

All data types are allowed, but field names starting with '$' are reserved for data querying.

If the document does not contain an _id field, DnDB will automatically generate one for you (a RFC4122 UUID alphanumerical string). The _id of a document, once set, shouldn't be modified.

let obj = {
  name: "denyn",
  lastName: "crawford",
};

let insertion = await db.insert(obj);

// OR

db.insert(obj, (insertion) => {
  // ...foo(insetion)
});

To insert documents DnDB exposes the method:

  • insert:

  • returns: Array/object with the inserted documents.

The insert method receives two arguments:

  • data: Json data to insert
  • callback(optional): The callback function to get the data inserted.

You can also insert several documents at the same time by wrapping them in an array.

let foo = "foo";

db.insert([{ name: "denyn" }, { name: foo }], (insertion) => {
  // ...foo(insetion)
});

πŸ” Finding documents

To find documents DnDB exposes the methods:

  • find: Finds all the documents that match the query.

    • returns: array of matching documents
  • findOne: Finds the first document that matches the query.

    • returns: exact first matching object

You can select documents based on field equality or use comparison operators ($lt, $lte, $gt, $gte, $in, $nin, $neq). You can also use logical operators $or, $and, $not and $eq. See below for the syntax.

You can use regular expressions in two ways: in basic querying in place of a string, or with the $regex operator.

Example of document querying:

Notice: See all rules and operators list here

db.find({ name: "Denyn" }, {}, (docs) => {
  console.log(docs);
});

// or

let docs = await db.find({ name: "Denyn" });

// Finding unique document

let docs = await db.findOne({ username: "denyncrawford" });

// Deep querying syntax:

let docs = await db.find({ fullName: { lastName: "Crawford" } });

You can also use dot notation to find documents by deep querying.

let docs = await db.find({ "fullName.lastName": "Crawford" });

// Using dot notation to find inside arrays:

let docs = await db.find({ "list.games.0": "Doom" });

If you want to know how to advance query documents please read this

Projections

You can give find and findOne an optional second argument, projections. The syntax is the same as MongoDB: { a: 1, b: 1 } to return only the a and b fields, { a: 0, b: 0 } to omit these two fields. You cannot use both modes at the time, except for _id which is by default always returned and which you can choose to omit. You can project on nested documents.

Notice: See all rules and operators list here

db.find({ planet: "Mars" }, { planet: 1, system: 1 }, function (docs) {
  // docs is [{ planet: 'Mars', system: 'solar', _id: 'id1' }]
});

πŸ–ŒοΈ Updating documents

To update documents DnDB exposes the method:

  • update

    • returns: array with the new updated collection
  • updateOne

    • returns: object with the new updated document.

The update method follows the same query rules as in find and findOne at first argument to get the update target document and as a second agument it receives the aggregation operators that modifies the matching fileds values ​​by following the aggregation rules.

Notice: See all rules and operators list here

db.update({ name: "denyn" }, { $set: { pet: "Boots" } }, (update) => {
  // ...foo(update)
});

// OR

let update = await db.update({ name: "denyn" }, { $set: { pet: "Boots" } });

❌ Removing documents

To remove documents DnDB exposes the method:

  • remove

    • returns: array with the new removed collection
  • removeOne

    • returns: object with the new removed document

The remove method follows the same query rules as in find and findOne at first argument, it will remove all the documents that matches the query.

db.remove({ _id: "id2" }, function (newDoc) {
  // ...foo(newDoc)
});

//OR

const { remove } = db;

await remove({ _id: "id2" });

Notice: If you want to unset a value from the document you must use update with the $unset operator. See all rules and operators list here

πŸ“ Roadmap

  • Standard methods
  • Database from datastores factory
  • Read and write streams and buffer
  • Global Queue executor
  • Event hooks on all the API usage
  • Count method
  • Improve documentation
  • Prevent updating immutable data
  • Error handlers.
  • SORT, SKIP, and LIMIT modifier methods support.

πŸ“Œ This module is right now on Beta, but the main API is pretty usable for production.

Since it is a standard, the API will not be subject to drastic changes, but its internal working will.

πŸ‘Š Support this project by donating on:

  • Paypal.
  • BTC address: 1AwAW9gj7zsHWjoawm1yFntjE69uvEjJTv
  • USDT adress (BSC) 0x9c83792244a8ee2e5b4c595b001ad8d7173e98bf
  • USDT adress (ERC20) 0x9c83792244a8ee2e5b4c595b001ad8d7173e98bf

πŸ“œ MIT License

Copyright (c) Crawford.

FOSSA Status

Full license

Scripts

Type Command
Format deno fmt
Lint deno lint --unstable --ignore=test,demo
Test deno test --unstable --allow-read=. --allow-write=db.db,db.db.updated
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].