### Installing RQL with CPM Source: https://github.com/kriszyp/rql/blob/master/README.md This command demonstrates how to install the RQL library using CPM. CPM is another package manager. ```Shell cpm install rql ``` -------------------------------- ### Installing RQL with RingoJS Source: https://github.com/kriszyp/rql/blob/master/README.md This command demonstrates how to install the RQL library using RingoJS's package manager. RingoJS is a JavaScript platform. ```Shell ringo-admin install persvr/rql ``` -------------------------------- ### Simple RQL Query Example Source: https://github.com/kriszyp/rql/blob/master/README.md This example demonstrates a simple RQL query that searches for resources with a property 'foo' equal to 3. It showcases the basic syntax of RQL with the 'eq' operator. ```rql eq(foo,3) ``` -------------------------------- ### Installing RQL with NPM Source: https://github.com/kriszyp/rql/blob/master/README.md This command demonstrates how to install the RQL library using NPM (Node Package Manager). NPM is a popular package manager for JavaScript. ```Shell npm install rql ``` -------------------------------- ### Creating and Executing RQL Query in JavaScript Source: https://github.com/kriszyp/rql/blob/master/README.md This example demonstrates how to create and execute an RQL query in JavaScript using the 'rql/query' module. It shows how to use chained operator calls to construct a query that searches for resources with a property 'foo' equal to 3. ```javascript var Query = require("rql/query").Query; var fooEq3Query = new Query().eq("foo",3); ``` -------------------------------- ### HTML Form URL Encoding Equivalent Source: https://github.com/kriszyp/rql/blob/master/README.md This example shows the equivalent of the RQL query 'eq(foo,3)' using standard HTML form URL encoding. This demonstrates RQL's compatibility with standard URL encoding. ```html foo=3 ``` -------------------------------- ### Accessing nested properties in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates how to access nested properties in RQL using an array of properties or slashes as shorthand. Both examples are equivalent. ```rql (foo,bar)=3 ``` ```rql foo/bar=3 ``` -------------------------------- ### Initializing Query Object with rql/query in JavaScript Source: https://github.com/kriszyp/rql/blob/master/README.md This code snippet demonstrates how to import the Query object from the rql/query module and create a new query instance. The Query object is used to construct RQL queries programmatically. ```JavaScript var newQuery = require("rql/query").Query(); ``` -------------------------------- ### Filtering with 'lt' operator in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates filtering resources with a 'price' property less than 10 using the 'lt' (less than) operator in RQL. It shows both the FIQL syntax and the normalized form. ```rql price=lt=10 ``` ```rql lt(price,10) ``` -------------------------------- ### Executing RQL query against JavaScript array Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet shows how to execute an RQL query against a JavaScript array using the `rql/js-array` module. It requires the `rql/js-array` module. ```javascript require("rql/js-array").executeQuery("foo=3&price=lt=10", {}, data) ``` -------------------------------- ### Combining conditions with 'or' and grouping in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates combining conditions with the '|' (or) operator and using parentheses to group expressions in RQL. It shows the equivalent expression using the 'and' and 'or' operators. ```rql (foo=3|foo=bar)&price=lt=10 ``` ```rql and(or(eq(foo,3),eq(foo,bar)),lt(price,10)) ``` -------------------------------- ### Sorting by multiple properties in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates how to sort by multiple properties using the 'sort' operator. It sorts by 'price' in ascending order and 'rating' in descending order. ```rql sort(+price,-rating) ``` -------------------------------- ### Constructing RQL Query with rql/query in JavaScript Source: https://github.com/kriszyp/rql/blob/master/README.md This code snippet shows how to construct an RQL query using the Query object and its methods (lt and gt). It creates a query that filters for values of 'foo' that are less than 3 and greater than 10. ```JavaScript var Query = require("rql/query").Query; var fooBetween3And10Query = new Query().lt("foo",3).gt("foo",10); ``` -------------------------------- ### Combining conditions with '&' operator in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates combining multiple conditions using the '&' operator in RQL. It shows different ways to express the same condition, including using the 'and' operator. ```rql foo=3&price=lt=10 ``` ```rql eq(foo,3)<(price,10) ``` ```rql and(eq(foo,3),lt(price,10)) ``` -------------------------------- ### Sorting with 'sort' operator in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates how to use the 'sort' operator to sort by a specified property in ascending order. It also includes a filter condition. ```rql price=lt=10&sort(+foo) ``` -------------------------------- ### Parsing RQL String with rql/parser in JavaScript Source: https://github.com/kriszyp/rql/blob/master/README.md This code snippet demonstrates how to parse an RQL string into a query object using the parseQuery function from the rql/parser module. The resulting query object represents the parsed RQL query. ```JavaScript var parsedQueryObject = require("rql/parser").parseQuery(rqlString); ``` -------------------------------- ### Aggregation with 'aggregate' function in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates how to use the 'aggregate' function to calculate the sum of sales for each department. It groups by 'departmentId' and calculates the sum of 'sales'. ```rql aggregate(departmentId,sum(sales)) ``` -------------------------------- ### Specifying string type explicitly in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates how to explicitly specify the string type in an RQL query. This is useful when you need to differentiate between a number and a string with the same value. ```rql foo=string:3 ``` -------------------------------- ### Parsing Complex RQL String with rql/parser in JavaScript Source: https://github.com/kriszyp/rql/blob/master/README.md This code snippet shows how to parse a complex RQL string with multiple conditions and operators into a nested query object. The resulting object represents the parsed RQL query with its name and arguments. ```JavaScript require("rql/parser").parseQuery("(foo=3|foo=bar)&price=lt=10") -> { name: "and", args: [ { name:"or", args:[ { name:"eq", args:["foo",3] }, { name:"eq", args:["foo","bar"] } ] }, { name:"lt", args:["price",10] } ] } ``` -------------------------------- ### Using 'in' operator with array values in RQL Source: https://github.com/kriszyp/rql/blob/master/README.md This snippet demonstrates using the 'in' operator to find objects where the 'foo' property matches any of the values in the provided array. The array contains a number, a string, a boolean, and a date. ```rql foo=in=(3,bar,true,2000-01-01T00:00:00Z) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.