Giter Site home page Giter Site logo

easydb's Introduction

easydb

Easy oriented objects encrypted databse

How to install

$ npm install easydb

How to use

var easydb = require("easydb");
var db = new easydb(file, password)
//If file doesn't exist, It will be created.
  • file: string
  • password (optional): string

Create Group

//Groups are like tables in a SQL database
db.createGroup(group)
//The group will only be created if it doesn't exist
  • group: string

Delete Group

db.deleteGroup(group)
  • group: string

Rename Group

db.renameGroup(oldName, newName)
  • oldName: string
  • newName: string

Insert data

db.insert(group, data)
  • group: string
  • data: any type of data

Select data

var dataArray = db.select(group, where)
//It returns an array of data. Setting
//Setting where to "$", it will return all data
  • group: string
  • where: string or function (See linq.js: linq.js)

Delete data

db.delete(group, where)
//Setting where to "$", it will delete all data
  • group: string
  • where: string or function (See linq.js: linq.js)

Update data

db.update(group, where, data)
//Setting where to "$", it will update all data
  • group: string
  • where: string or function (See linq.js: linq.js)
  • data: any type of data (See linq.js: linq.js)

Examples

var easydb = require("easydb")
var db = new easydb("mybase", "mypassword")

/*Create group*/
db.createGroup("students")
db.createGroup("animals")

/*Delete group*/
db.deleteGroup("animals")

/*Rename group*/
db.renameGroup("students", "people")

/*Insert data*/
db.insert("people", {id: "#", name: "Samuel Novaes", age: 19, occupation: "student"})
//Creating a property called "id" and setting its value to "#", we have an auto increment

/*Select data*/
var people = db.select("people", "$.age < 20")
people.forEach(function(item){
  console.log(item.name)
})

/*Update data*/
db.update("people", "$.age > 25", function(x){
  x.occupation = "teacher"
  return x
})

/*Delete data*/
db.delete("people", "$.id == 1")

easydb's People

Contributors

samuelnovaes avatar

Watchers

James Cloos avatar Cesar Marinho avatar

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.