Giter Club home page Giter Club logo

peak.db's Introduction


About

Fast and advanced, document based NoSQL database that able to work as it is installed.

Features

  • NoSQL database
  • Can be run as it is installed
  • Customizable settings for collections
  • Quick data reading and writing
  • Automatically or manual backup
  • No need to use schema
  • Easy to find data

Usage

Installation

npm install peak.db --save

Create a Collection

const PeakDB = require("peak.db");
var accounts = new PeakDB.Collection({
  "name": "ACCOUNTS", // Name of collection (required)
  "id_length": 32, // This determines the length of unique identities given to documents. (no required, default: 32)
  "delete_backups_before_this_day": 3, // This determines how many days of backups will be deleted. (no required, default: 3)
  "auto_backup": true, // If active this, this collection will receive automatic backups. (no required, default: false)
  "indicate_created_at": true, // If active this, will be automatically specified date when documents are created. (no required, default: false)
  "indicate_created_timestamp": true, // If active this, will be automatically specified timestamp when documents are created. (no required, default: false)
  "indicate_updated_at": true, // If active this, will be automatically specified date when documents are updated. (no required, default: false)
  "indicate_updated_timestamp": true // If active this, will be automatically specified timestamp when documents are updated. (no required, default: false)
});

Insert a Document

accounts.insert({"email": "[email protected]", "username": "fir4tozden", "password": "12345678", "region": "Muğla"});
/*
  {
    "_id": "RMmXZVDfQrVLQwFlquMPb98XNUCxQ6MM",
    "_updated": false,
    "_created_at": 2022-03-20T00:00:00.000Z,
    "_created_timestamp": 1647745200000,
    "email": "[email protected]",
    "username": "fir4tozden",
    "password": "12345678",
    "region": "Muğla"
  }
*/

Find a Document

accounts.find(document => document.email === "[email protected]");
/*
  {
    "_id": "RMmXZVDfQrVLQwFlquMPb98XNUCxQ6MM",
    "_updated": false,
    "_created_at": 2022-03-20T00:00:00.000Z,
    "_created_timestamp": 1647745200000,
    "email": "[email protected]",
    "username": "fir4tozden",
    "password": "12345678",
    "region": "Muğla"
  }
*/

Filter Documents

accounts.filter(document => document.region === "Muğla");
/*
  [
    {
      "_id": "RMmXZVDfQrVLQwFlquMPb98XNUCxQ6MM",
      "_updated": false,
      "_created_at": 2022-03-20T00:00:00.000Z,
      "_created_timestamp": 1647745200000,
      "email": "[email protected]",
      "username": "fir4tozden",
      "password": "12345678",
      "region": "Muğla"
    },
    {
      "_id": "23ERK9fHqiH_n83fhzU7eOYtzz6tUl7S",
      "_updated": false,
      "_created_at": 2022-03-20T00:05:00.000Z,
      "_created_timestamp": 1647734700000,
      "email": "[email protected]",
      "username": "nehir",
      "password": "12345678",
      "region": "Muğla"
    }
  ]
*/

Update a Document

let document = accounts.find(document => document.email === "[email protected]");
accounts.update(document._id, {"email": "[email protected]", "username": "hey_im_fir4tozden", "password": "87654321", "region": "İstanbul"});
/*
  {
    "_id: "23ERK9fHqiH_n83fhzU7eOYtzz6tUl7S",
    "_updated": true,
    "_created_at": 2022-03-20T00:00:00.000Z,
    "_created_timestamp": 1647745200000,
    "_updated_at": 2022-03-20T00:10:00.000Z,
    "_updated_timestamp": 1647735000000,
    "email": "[email protected]",
    "username": "hey_im_fir4tozden",
    "password": "87654321",
    "region": "İstanbul"
  }
*/

Delete a Document

let document = accounts.find(document => document.email === "[email protected]");
accounts.delete(document._id);
// true

Backup Collection

accounts.backup();
// true

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.