Git Product home page Git Product logo

jsonql-totaljs's Introduction

jsonql-totaljs

NPM

npm version Build Status Coverage Status JavaScript Style Guide Known Vulnerabilities dependencies Status License NPM download/month NPM download total
JsonQL NoSQL Embedded for Total.js Framework.

This will make you easier to use NoSQL Embedded in Total.js Framework.

Get Started

Install using NPM

$ npm install jsonql-totaljs

Usage

  • Basic Query
const JsonQL = require('jsonql-totaljs');
// create new object jsonql
const jsonql = new JsonQL();

// build query
var q = [
    {
        select: {
            fields:['user_id','name'],
            from:'user',
            where:[
                ['name','==','budi']
            ]
        }
    }
];

// with callback
jsonql.query(q).exec(function(err,data) {
    console.log(data);        
});

// on top promise
jsonql.query(q).promise().then((data) => {
    console.log(data);        
});
  • Multiple Query in Single Execution
var q = [
    {
        select: {
            from:'user',
            where:[
                ['name','==','wawan']
            ]
        }
    },
    {
        select: {
            from:'profile',
            where:[
                ['address','==','jakarta']
            ]
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});
  • Join Query
var q = [
   {
       select: {
           from:'user',
           where:[
               ['name','==','budi']
           ],
           join:[
               {
                   name:'profile',
                   from:'user_profile',
                   on:['id','id'],
                   first:true
               }
           ]
       }
   }
];

jsonql.query(q).exec(function(err,data) {
   console.log(data);        
});
  • Join Nested
var q = [
    {
        select: {
            from:'user',
            where:[
                ['name','==','budi']
            ],
            join:[
                {
                    name:'profile',
                    from:'user_profile',
                    on:['id','id'],
                    first:true,
                    join:[
                        {
                            name:'additional',
                            from:'user_other',
                            on:['id','id'],
                            first:false
                        }
                    ]
                }
            ]
        }
    }
];

jsonql.query(q).exec(function(err,data) {
    console.log(data);        
});
  • Join Nested Manually
var q = [
    {
        select: {
            from:'user',
            where:[
                ['name','==','budi']
            ],
            join:[
                {
                    name:'profile',
                    from:'user_profile',
                    on:['id','id'],
                    first:true
                },
                {
                    name:'additional',
                    from:'user_other',
                    on:['id','id'],
                    first:false
                }
            ],
            nested:['profile','additional']
        }
    }
];

jsonql.query(q).exec(function(err,data) {
    console.log(data);        
});
  • Insert Single
var q = [
    {
        insert: {
            into:'data_crud',
            values:[
                {
                    id:'1',
                    name:'aziz'
                }
            ]
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});
  • Insert Multiple
var q = [
    {
        insert: {
            into:'data_crud',
            values:[
                {
                    id:'1',
                    name:'aziz'
                },
                {
                    id:'2',
                    name:'tika'
                }
            ]
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});
  • Update
var q = [
    {
        update: {
            from:'data_crud',
            where:[
                ['name','==','aziz']
            ],
            set:{
                id:'1',
                name:'aziz alfian'
            }
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});
  • Modify
var q = [
    {
        modify: {
            from:'data_crud',
            where:[
                ['name','==','aziz']
            ],
            set:{
                name:'M ABD AZIZ ALFIAN'
            }
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});
  • Delete
var q = [
    {
        delete: {
            from:'data_crud',
            where:[
                ['name','==','aziz']
            ]
        }
    }
];
    
jsonql.query(q).exec(function(err,data) {
    console.log(data);
});

Documentation

For more detail in usage, please see the documentation in our Wiki.

Unit Test

All features has been tested, you also can learn how to use all features from unit test.

$ npm test

jsonql-totaljs's People

Contributors

aalfiann avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

mikebaumgart

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.