object-querybuilder
v1.0.3
Published
JavaScript Object Query Builder
Downloads
4
Maintainers
Readme
Object type data query builder
🕹Guide
Install
$ npm install --save object-querybuilder
Usage
JavaScript
const query = require('object-querybuilder');
const users = [
{ name: 'Lucy', age: 23, gender: 'woman' },
{ name: 'Emma', age: 31, gender: 'woman' },
{ name: 'Daniel', age: 18, gender: 'man' },
{ name: 'Olivia', age: 42, gender: 'woman' },
{ name: 'Alex', age: 33, gender: 'man' }
];
const countrys = [
{ name: 'Lucy', country: 'New York' },
{ name: 'Daniel', country: 'France' },
{ name: 'Emma', country: 'Germany' }
];
const result = query
.select(['*'])
.from(users)
.join(countrys, 'name')
.where('age', '>', 30)
.run();
/**
[
{ name: 'Emma', age: 31, gender: 'woman', country: 'Germany' }
]
**/
TypeScript
import query from 'object-querybuilder';
const users = [
{ name: 'Lucy', age: 23, gender: 'woman' },
{ name: 'Emma', age: 31, gender: 'woman' },
{ name: 'Daniel', age: 18, gender: 'man' },
{ name: 'Olivia', age: 42, gender: 'woman' },
{ name: 'Alex', age: 33, gender: 'man' }
];
const countrys = [
{ name: 'Lucy', country: 'New York' },
{ name: 'Daniel', country: 'France' },
{ name: 'Emma', country: 'Germany' }
];
const result = query
.select(['*'])
.from(users)
.join(countrys, 'name')
.where('age', '>', 30)
.run();
/**
[
{ name: 'Emma', age: 31, gender: 'woman', country: 'Germany' }
]
**/
📬 Recommended Commit Message
| When | Commit Message | |:--------|:-----------| | Add function | feat: ⚡️ Add function | | Fix bug | fix: 🐞 Fix bug | | Refactoring | refactor: 🛠 Refactoring | | Add package | package: 📦 Add package | | Fix readme | docs: 📚 Fix readme | | Improvements style | style: 👁 Improvements style | | New Releases | releases: 🎉 Releases |