{"_id":"rql","_rev":"19-5db9fb01e9b2ff28e30f4d703c24155a","name":"rql","description":"Query language for the web, NoSQL","dist-tags":{"latest":"0.3.3"},"versions":{"0.2.2":{"name":"rql","version":"0.2.2","author":{"name":"Kris Zyp"},"contributors":[{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"}],"keywords":["resource","query","uri"],"description":"Query language for the web, NoSQL","licenses":[{"type":"AFLv2.1","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"},{"type":"BSD","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"}],"directories":{"lib":"."},"repository":{"type":"git","url":"http://github.com/kriszyp/rql"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"mappings":{"patr":"http://github.com/kriszyp/patr/zipball/v0.2.1","promised-io":"http://github.com/kriszyp/promised-io/zipball/v0.2.1"},"dependencies":{"promised-io":">0.2.3"},"devDependencies":{"patr":">0.2.6"},"icon":"http://packages.dojofoundation.org/images/persvr.png","_id":"rql@0.2.2","dist":{"shasum":"dd909c38590da37a11e149869d71660abd2bfced","tarball":"https://registry.npmjs.org/rql/-/rql-0.2.2.tgz","integrity":"sha512-FMHGmKGSmmwqEHy/ii+0JAa12euhnhiL82yf2soWQcocr0bafIqayZbdZV0+EFD1f7J9UOSeEXZMI0ziHuroeA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD1/3Sl6WBsEdxnDkwKc18lAG4Eujq74SEOkS34WKVdQwIhAMHp505fEOwCjrVQz12BOMk+JsBit+WLGtHtVmcLcoFa"}]},"scripts":{}},"0.3.1":{"name":"rql","version":"0.3.1","author":{"name":"Kris Zyp"},"contributors":[{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"}],"keywords":["resource","query","uri"],"description":"Query language for the web, NoSQL","licenses":[{"type":"AFLv2.1","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"},{"type":"BSD","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"}],"directories":{"lib":"."},"repository":{"type":"git","url":"http://github.com/kriszyp/rql"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"mappings":{"patr":"http://github.com/kriszyp/patr/zipball/v0.2.1","promised-io":"http://github.com/kriszyp/promised-io/zipball/v0.2.1"},"dependencies":{"promised-io":">0.2.3"},"devDependencies":{"patr":">0.2.6"},"icon":"http://packages.dojofoundation.org/images/persvr.png","_id":"rql@0.3.1","dist":{"shasum":"2128b875bfd4ad26c4ed6dfd6258e588413e9eaa","tarball":"https://registry.npmjs.org/rql/-/rql-0.3.1.tgz","integrity":"sha512-Sp4DMsW/8ONTqwl+1NI1Z68n0AttCyx/cLncIURvInWxPlN3pR56IJoRxjwS79DgzZ+WjSr+VRrCbpGUd7NEWw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoxBJuL+xH6Zfs3sans15N5RZDcid11Zrjbt4V0skQcgIgD6Mb/ya1ZedGS+weWi1leTD7DhGyNNLZ5evNBdteROU="}]},"scripts":{}},"0.3.2":{"name":"rql","version":"0.3.2","author":{"name":"Kris Zyp"},"contributors":[{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"}],"keywords":["resource","query","uri"],"description":"Query language for the web, NoSQL","licenses":[{"type":"AFLv2.1","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"},{"type":"BSD","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"}],"directories":{"lib":"."},"repository":{"type":"git","url":"http://github.com/kriszyp/rql"},"maintainers":[{"name":"kriszyp","email":"kriszyp@gmail.com"}],"mappings":{"patr":"http://github.com/kriszyp/patr/zipball/v0.2.1","promised-io":"http://github.com/kriszyp/promised-io/zipball/v0.2.1"},"dependencies":{"promised-io":">=0.3.0"},"devDependencies":{"patr":">0.2.6"},"icon":"http://packages.dojofoundation.org/images/persvr.png","dojoBuild":"package.js","bugs":{"url":"https://github.com/kriszyp/rql/issues"},"homepage":"https://github.com/kriszyp/rql","_id":"rql@0.3.2","dist":{"shasum":"60d710156deb8e3ea4176fc7f329e77ef6a3f99b","tarball":"https://registry.npmjs.org/rql/-/rql-0.3.2.tgz","integrity":"sha512-TTnjsfE1NUN+BPz35kWsMT7sdipuMX7AexF9oWh+aKu8pVVBR+41HyfKzoeaijy1dLeejMv3OC/Khjrz4+gF+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAbm/9uazoGXg9i1zF9o9B6bdEJ+zN/RHupYlyDrxvYzAiA/uWtvEgVfAvSuaeo+6r7VBAf2zxDqcSiOQ/B9JgSzCQ=="}]},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"kriszyp","email":"kriszyp@gmail.com"}},"0.3.3":{"name":"rql","version":"0.3.3","author":{"name":"Kris Zyp"},"contributors":[{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"}],"keywords":["resource","query","uri"],"description":"Query language for the web, NoSQL","licenses":[{"type":"AFLv2.1","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"},{"type":"BSD","url":"http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"}],"directories":{"lib":"."},"repository":{"type":"git","url":"http://github.com/kriszyp/rql"},"maintainers":[{"name":"kriszyp","email":"kriszyp@gmail.com"}],"mappings":{"patr":"http://github.com/kriszyp/patr/zipball/v0.2.1","promised-io":"http://github.com/kriszyp/promised-io/zipball/v0.2.1"},"dependencies":{"promised-io":">=0.3.0"},"devDependencies":{"intern-geezer":"^2.1.1"},"scripts":{"test":"intern-client config=test/intern","test.sauce":"intern-runner config=test/intern","test.proxy":"intern-runner config=test/intern --proxyOnly"},"icon":"http://packages.dojofoundation.org/images/persvr.png","dojoBuild":"package.js","bugs":{"url":"https://github.com/kriszyp/rql/issues"},"homepage":"https://github.com/kriszyp/rql","_id":"rql@0.3.3","dist":{"shasum":"197aa431658b5a6f88c6af34e90f905e97994801","tarball":"https://registry.npmjs.org/rql/-/rql-0.3.3.tgz","integrity":"sha512-J8v4kt1R0Sc8TYKHN0aDcc3uZtYytCyDfaTsvrJ9u2YOkjm9Q9nQ+9JPUq6kTBenskdhmW9oxKuj6sSBmqVLzQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCT2PrKeiuQzL0Glxl6lMqKfhz2lbZV69Qjlz9fCbhG5wIgBM9K43kMqNDpPkAXJthKPfbHrgSDCDigiKEzB/Y/W4Q="}]},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"kriszyp","email":"kriszyp@gmail.com"}}},"readme":"[![Build Status](https://travis-ci.org/persvr/rql.svg?branch=master)](https://travis-ci.org/persvr/rql)\r\n\r\nResource Query Language (RQL) is a query language designed for use in URIs with object\r\nstyle data structures. This project includes the RQL specification and\r\nprovides a JavaScript implementation of query\r\nparsing and query execution implementation for JavaScript arrays. The JavaScript library\r\nsupports AMD and NodeJS/CommonJS module format so it can be run in the browser or\r\nin the server. RQL can be thought as basically a set of\r\nnestable named operators which each have a set of arguments. RQL is designed to\r\nhave an extremely simple, but extensible grammar that can be written in a URL friendly query string. A simple RQL\r\nquery with a single operator that indicates a search for any resources with a property of\r\n\"foo\" that has value of 3 could be written:\r\n\r\n    eq(foo,3)\r\n\r\nRQL is a compatible superset of standard HTML form URL encoding. The following query\r\nis identical to the query (it is sugar for the query above):\r\n\r\n    foo=3\r\n\r\nSuch that this can be used in URIs like:\r\n\r\n    http://example.org/data?foo=3\r\n\r\n# JavaScript Library\r\n\r\nUsing the JavaScript library we can construct queries\r\nusing chained operator calls in JavaScript. We could execute the query above like this:\r\n\r\n    var Query = require(\"rql/query\").Query;\r\n    var fooEq3Query = new Query().eq(\"foo\",3);\r\n\r\n# RQL Rules\r\n\r\nThe RQL grammar is based around standard URI delimiters. The standard rules for\r\nencoding strings with URL encoding (%xx) are observed. RQL also supersets FIQL.\r\nTherefore we can write a query that finds resources with a \"price\" property below\r\n10 with a \"lt\" operator using FIQL syntax:\r\n\r\n    price=lt=10\r\n\r\nWhich is identical (and sugar for call operator syntax known as the normalized form):\r\n\r\n    lt(price,10)\r\n\r\nOne can combine conditions with multiple operators with \"&\":\r\n\r\n    foo=3&price=lt=10\r\n\r\nIs the same as:\r\n\r\n    eq(foo,3)&lt(price,10)\r\n\r\nWhich is also the same as:\r\n\r\n    and(eq(foo,3),lt(price,10))\r\n\r\nWe can execute a query against a JavaScript array:\r\n\r\n\trequire(\"rql/js-array\").executeQuery(\"foo=3&price=lt=10\", {}, data)...\r\n\r\nThe | operator can be used to indicate an \"or\" operation. We can also use paranthesis\r\nto group expressions. For example:\r\n\r\n    (foo=3|foo=bar)&price=lt=10\r\n\r\nWhich is the same as:\r\n\r\n    and(or(eq(foo,3),eq(foo,bar)),lt(price,10))\r\n\r\nValues in queries can be strings (using URL encoding), numbers, booleans, null, undefined,\r\nand dates (in ISO UTC format without colon encoding). We can also denote arrays\r\nwith paranthesis enclosed, comma separated values. For example to find the objects\r\nwhere foo can be the number 3, the string bar, the boolean true, or the date for the\r\nfirst day of the century we could write an array with the \"in\" operator:\r\n\r\n    foo=in=(3,bar,true,2000-01-01T00:00:00Z)\r\n\r\nWe can also explicitly specify primitive types in queries. To explicitly specify a string \"3\",\r\nwe can do:\r\n\r\n    foo=string:3\r\n\r\nAny property can be nested by using an array of properties. To search by the bar property of\r\nthe object in the foo property we can do:\r\n\r\n    (foo,bar)=3\r\n\r\nWe can also use slashes as shorthand for arrays, so we could equivalently write the nested\r\nquery:\r\n\r\n    foo/bar=3\r\n\r\nAnother common operator is sort. We can use the sort operator to sort by a specified property.\r\nTo sort by foo in ascending order:\r\n\r\n\tprice=lt=10&sort(+foo)\r\n\r\nWe can also do multiple property sorts. To sort by price in ascending order and rating in descending order:\r\n\r\n    sort(+price,-rating)\r\n\r\nThe aggregate function can be used for aggregation. To calculate the sum of sales for\r\neach department:\r\n\r\n    aggregate(departmentId,sum(sales))\r\n\r\nHere is a definition of the common operators (individual stores may have support\r\nfor more less operators):\r\n\r\n* sort(&lt;+|->&lt;property) - Sorts by the given property in order specified by the prefix (+ for ascending, - for descending)\r\n* select(&lt;property>,&lt;property>,...) - Trims each object down to the set of properties defined in the arguments\r\n* values(&lt;property>) - Returns an array of the given property value for each object\r\n* aggregate(&lt;property|function>,...) - Aggregates the array, grouping by objects that are distinct for the provided properties, and then reduces the remaining other property values using the provided functions\r\n* distinct() - Returns a result set with duplicates removed\r\n* in(&lt;property>,&lt;array-of-values>) - Filters for objects where the specified property's value is in the provided array\r\n* out(&lt;property>,&lt;array-of-values>) - Filters for objects where the specified property's value is not in the provided array\r\n* contains(&lt;property>,&lt;value | expression>) - Filters for objects where the specified property's value is an array and the array contains any value that equals the provided value or satisfies the provided expression.\r\n* excludes(&lt;property>,&lt;value | expression>) - Filters for objects where the specified property's value is an array and the array does not contain any of value that equals the provided value or satisfies the provided expression.\r\n* limit(count,start,maxCount) - Returns the given range of objects from the result set\r\n* and(&lt;query>,&lt;query>,...) - Applies all the given queries\r\n* or(&lt;query>,&lt;query>,...) - The union of the given queries\r\n* eq(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is equal to the provided value\r\n* lt(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is less than the provided value\r\n* le(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is less than or equal to the provided value\r\n* gt(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is greater than the provided value\r\n* ge(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is greater than or equal to the provided value\r\n* ne(&lt;property>,&lt;value>) - Filters for objects where the specified property's value is not equal to the provided value\r\n* rel(&lt;relation name?>,&lt;query>) - Applies the provided query against the linked data of the provided relation name.\r\n* sum(&lt;property?>) - Finds the sum of every value in the array or if the property argument is provided, returns the sum of the value of property for every object in the array\r\n* mean(&lt;property?>) - Finds the mean of every value in the array or if the property argument is provided, returns the mean of the value of property for every object in the array\r\n* max(&lt;property?>) - Finds the maximum of every value in the array or if the property argument is provided, returns the maximum of the value of property for every object in the array\r\n* min(&lt;property?>) - Finds the minimum of every value in the array or if the property argument is provided, returns the minimum of the value of property for every object in the array\r\n* recurse(&lt;property?>) - Recursively searches, looking in children of the object as objects in arrays in the given property value\r\n* first() - Returns the first record of the query's result set\r\n* one() - Returns the first and only record of the query's result set, or produces an error if the query's result set has more or less than one record in it.\r\n* count() - Returns the count of the number of records in the query's result set\r\n\r\n# JavaScript Modules\r\n\r\n## rql/query\r\n\r\n    var newQuery = require(\"rql/query\").Query();\r\n\r\nThis module allows us to construct queries. With the query object, we could execute\r\nRQL operators as methods against the query object. For example:\r\n\r\n    var Query = require(\"rql/query\").Query;\r\n    var fooBetween3And10Query = new Query().lt(\"foo\",3).gt(\"foo\",10);\r\n\r\n## rql/parser\r\n\r\n\tvar parsedQueryObject = require(\"rql/parser\").parseQuery(rqlString);\r\n\r\nIf you are writing an implementation of RQL for a database or other storage endpoint, or want to introspect queries, you can use the parsed query data\r\nstructures. You can parse string queries with parser module's parseQuery function.\r\nQuery objects have a \"name\" property and an \"args\" with an array of the arguments.\r\nFor example:\r\n\r\n\trequire(\"rql/parser\").parseQuery(\"(foo=3|foo=bar)&price=lt=10\") ->\r\n\t{\r\n\t\tname: \"and\",\r\n\t\targs: [\r\n\t\t\t{\r\n\t\t\t\tname:\"or\",\r\n\t\t\t\targs:[\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tname:\"eq\",\r\n\t\t\t\t\t\targs:[\"foo\",3]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tname:\"eq\",\r\n\t\t\t\t\t\targs:[\"foo\",\"bar\"]\r\n\t\t\t\t\t}\r\n\t\t\t\t]\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tname:\"lt\",\r\n\t\t\t\targs:[\"price\",10]\r\n\t\t\t}\r\n\t\t]\r\n\t}\r\n\r\nInstallation\r\n========\r\n\r\nRQL can be installed using any standard package manager, for example with NPM:\r\n\r\n    npm install rql\r\n\r\nor CPM:\r\n\r\n    cpm install rql\r\n\r\nor RingoJS:\r\n\r\n    ringo-admin install persvr/rql\r\n\r\n\r\nLicensing\r\n--------\r\n\r\nThe RQL implementation is part of the Persevere project, and therefore is licensed under the\r\nAFL or BSD license. The Persevere project is administered under the Dojo foundation,\r\nand all contributions require a Dojo CLA.\r\n\r\nProject Links\r\n------------\r\n\r\nSee the main Persevere project for more information:\r\n\r\n### Homepage:\r\n\r\n* [http://persvr.org/](http://persvr.org/)\r\n\r\n### Mailing list:\r\n\r\n* [http://groups.google.com/group/json-query](http://groups.google.com/group/json-query)\r\n\r\n### IRC:\r\n\r\n* [\\#persevere on irc.freenode.net](http://webchat.freenode.net/?channels=persevere)\r\n","maintainers":[{"name":"kriszyp","email":"kriszyp@gmail.com"}],"time":{"modified":"2022-06-26T14:28:29.740Z","created":"2012-07-06T21:56:07.864Z","0.2.2":"2012-07-06T21:56:09.200Z","0.3.1":"2012-07-06T21:56:13.519Z","0.3.2":"2014-10-10T14:52:29.330Z","0.3.3":"2014-10-14T18:47:09.105Z"},"author":{"name":"Kris Zyp"},"repository":{"type":"git","url":"http://github.com/kriszyp/rql"},"keywords":["resource","query","uri"],"contributors":[{"name":"Vladimir Dronnikov","email":"dronnikov@gmail.com"}],"readmeFilename":"README.md","homepage":"https://github.com/kriszyp/rql","bugs":{"url":"https://github.com/kriszyp/rql/issues"},"users":{"klyngbaek":true}}