https://github.com/aalfiann/jsonql-totaljs
JsonQL NoSQL Embedded for Total.js Framework
https://github.com/aalfiann/jsonql-totaljs
json-query jsonql jsonql-nosql jsonql-totaljs totaljs
Last synced: 9 months ago
JSON representation
JsonQL NoSQL Embedded for Total.js Framework
- Host: GitHub
- URL: https://github.com/aalfiann/jsonql-totaljs
- Owner: aalfiann
- License: mit
- Created: 2019-11-24T04:35:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T12:46:04.000Z (almost 6 years ago)
- Last Synced: 2025-06-09T04:31:59.471Z (about 1 year ago)
- Topics: json-query, jsonql, jsonql-nosql, jsonql-totaljs, totaljs
- Language: JavaScript
- Homepage: https://nodei.co/npm/jsonql-totaljs/
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonql-totaljs
[](https://nodei.co/npm/jsonql-totaljs/)
[](https://www.npmjs.org/package/jsonql-totaljs)
[](https://travis-ci.com/aalfiann/jsonql-totaljs)
[](https://coveralls.io/github/aalfiann/jsonql-totaljs?branch=master)
[](https://standardjs.com)
[](https://snyk.io//test/github/aalfiann/jsonql-totaljs?targetFile=package.json)
[](https://david-dm.org/aalfiann/jsonql-totaljs)



JsonQL NoSQL Embedded for Total.js Framework.
This will make you easier to use [NoSQL Embedded](https://docs.totaljs.com/latest/en.html#api~DatabaseBuilder) in [Total.js Framework](https://totaljs.com).
## Get Started
### Install using NPM
```bash
$ npm install jsonql-totaljs
```
### Usage
- Basic Query
```javascript
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
```javascript
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
```javascript
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
```javascript
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
```javascript
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
```javascript
var q = [
{
insert: {
into:'data_crud',
values:[
{
id:'1',
name:'aziz'
}
]
}
}
];
jsonql.query(q).exec(function(err,data) {
console.log(data);
});
```
- Insert Multiple
```javascript
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
```javascript
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
```javascript
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
```javascript
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](https://github.com/aalfiann/jsonql-totaljs/wiki).
## Unit Test
All features has been tested, you also can learn how to use all features from unit test.
```bash
$ npm test
```