Giter Club home page Giter Club logo

kabin's Introduction

-- Welcome to Kabin! (alpha warning!)--

  This is a simple JSON file database for nodejs.
  The console (examples/prompt.js) has already connected to the sample database.

  Connect to a directory at path var db = new kabin.JSON({path: 'data'});
  Create a new record with db.insert('e', {x: 10, y: 20})
  Read data from a record with db.e.x => 10
  Write data to a record with d.e = {x: 1, y: 2}

  db.migrate() -> migrate to latest version. db.version is the current version.
  db.migrate({version: x}) -> migrate to version x. up or down depending on current version.

  Put a model in db/models. See Recipe.js for an example:
    {
      init: function (data) {
        this.data = data;
        if(!this.data.saved) { this.data.saved = 0; }
      },
      
      getIngredients: function () {
        return this.data.ingredients;
      },
      
      onSave: function () {
        this.data.saved += 1;
        return this.data;
      }
    }
  A model must have the onSave function which defines what json-data it saves.
  A JSON file with the field type, will check if such a model exists, and then create it.
  See db.data.b for an example of a Recipe class instance.
  Will probably make the saving more logical.
  Currently to save changes to db.data.b you need to write db.data.b = db.data.b.

kabin>

kabin's People

Contributors

tnlogy avatar

Stargazers

node-migrator-bot avatar  avatar

Watchers

 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.