Qreal: control your data 😎
qreal is small function to restructure data ( Array Objects ) and now you can use qlink to make resturcture data very easy
Installation
Use the npm to install qreal.
npm install qreal --save
or you can use yarn to install it
yarn add qreal
Usage
restructure data by write the name of the property.
Info : qreal return promise
const Qreal = const qreal = var data = name : 'jack' // OR { if style == 'UpperCase' return 'jack' else return 'jack' } age : 13 address : first : 'london' second : 'bridge' name : 'john' age : 23 address : first : 'berlin' second : 'germane' qreal // Result name : 'jack' address : first : 'london' name : 'john' address : first : 'berlin'
$take
TYPE : $Number$ or $Array$
$take provide you to specify count of items what do you want to take
qreal // Result name : 'jack'
examples :
// take first 3 items $take : 3 // skip first 3 items $take : -3 // take all items expect last 3 items $take : -3 // take item in index 3 in addition to 4 itmes after it $take : 3 4 // take item had { name : "lorem" } in addition to 4 items after it $take : name : "lorem" 4
$ignore
TYPE : $Array$
You can select items you don't want
qreal // Result name : 'jack' name : 'john'
$include
TYPE : $Function$
You can include items if you want 😜.
qreal // Result name : 'jack' adult: false name : 'john' adult: true
$keyName
TYPE: $String$ or $Function$
ARGS : [ Object , Key ]
$keyName provide you to change key name of object 😎.
name must 🤬 start with '@' if you select name from object
qreal // Result 'jack' : age : 13 'john' : age : 23
Aliases
HOW TO USE : "[name of item] : [alias]"
$keyName is not working with sub items 😥 but you can use aliases 😃
name must 🤬 start with '@' if you select name from object
qreal // Result newAddress: first: "london" london: second: "bridge" newAddress: first: "berlin" berlin: second: "germane"
$value
TYPE: $String$ or $Function$
ARGS : [ Object , Key ]
You can set value of object 😎.
name must 🤬 start with '@' if you select value from object
qreal // Result 13 23
qreal // Result name : 'jack' address : 'london' name : 'john' address : 'berlin'
Qreal.use( name, middleware )
ARGS ( arguments what pass to middleware ) : [ ( value of data ) ], Parent Object, query value and next function
Qreal.use method provide you to add middleware to data that can use for relationships between data
const _ = ;const auhors = ... name : 'George Orwell' age : 46 id : 3 ...const books = ... title : "Animal Farm" description : "Is an allegoircal novella by George Orwell." author : 3 // this is an ID of author ( data what pass to middleware ) ... qreal qreal // Result ... title : "Animal Farm" author : name : "George Orwell" age : 46 ...
and you can make sub middleware
const auhors = ... name : 'George Orwell' age : 46 books : id : 9 id : 3 ... const books = ... title : "Animal Farm" id : 9 description : "Is an allegoircal novella by George Orwell." author : 3 ... qreal qreal console)// Result ... author : books : title : "Animal Farm" ...
OR use value of query to do some thing
const Book = title : '452 Fehrenhight' description : 'be or not to be this is not any thing :>' tags : 'test' 'good' 'book' publisher : name : 'home screen' country : 'england' books : id : 0 id : 1 id : 2 id : 0 author : 0 qreal qreal // Result title : "452 FEHRENHIGHT"
License
You can make deep restructure data