![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@allstar/reql-builder
Advanced tools
Dynamic filter builder for rethinkdbdash inspired by https://github.com/node-tastypie/tastypie-rethink
You can use a number of special query string params to control how data is paged on the list endpoint. Namely -
limit
- Page size ( default 25 )offset
- The starting point in the listlimit=25&offset=50
would be the start of page 3
sorting is handled query param orderby where you can pass it the name of a field to sort on. Sorting is descending by default. Specifying a negetive field ( - ) would flip the order
You might have noticed the filtering field on the schema. One of the things that makes an API "Good" is the ability to use query and filter the data to get very specific subsets of data. Tastypie exposes this through the query string as field and filter combinations. By default, the resource doesn't have anything enabled, you need to specify which filters are allowed on which fields, or specify 1 to allow everything
Filter | function |
---|---|
gt | greater than |
gte | greater than or equal to |
lt | less than |
lte | less than or equal to |
in | Value in set ( [ 1,2,3 ]) |
nin | Value Not in set |
size | Size of set ( array length ) |
startswith | Case Sensitive string match |
istartswith | Case Insensitive string match |
endswith | Case Sensitive string match |
iendswith | Case Insensitive string match |
contains | Case Sensitive global string match |
icontains | Case Insensitive global string match |
exact ( = ) | Exact Case Sensitive string match |
iexact | Exact Case Insensitive string match |
isnull | matches null values |
month | Matches date values on a specific month |
day | Matches date values on a speciec day of the week |
year | Matches date values on a specific year |
all | Matches all elements in an array |
range | Matches dates withing a specified range |
ne | not equal to |
Filters are added by appending a double underscore __
and the filter type to the end of a field name. Given our example, if we wanted to find people who were older than 25, we would use the following URI syntax
http://localhost:3000/api/v1/user?age__gt=25
Filters are additive for a given field. For example, if we we only wanted people where we between 25 and 45, we would just add another filter
http://localhost:3000/api/v1/user?age__gt=25&age__lt=45
The same double underscore __
syntax is used to access nested fields where the filter is always the last parameter. So we could find people whos age was greater than 25, less than 45 and whose Company Name starts with W
http://localhost:3000/api/v1/user?age__gt=25&age__lt=45&company__name__istartswith=w
expressions with no filters will use the default exact
filter
http://localhost:3000/api/v1/user?age=44
<rethinkdbdash>
, filters <Object>
): Query
r
- a rethinkdb dash connection w/ a default database configuredfilters
- an object to generate a query from. Typically a result from querystring.parser.filter
Given a table of user records
{
"email": "billybob@bobsfarms.biz"
, name: {
"first": "Billy"
, "last": "Bob"
}
}
const qs = require('querystring')
const {filter} = require('@allstar/reql-builder')
const r = require('rethinkdbdash')({db: 'test'})
// emails w/ .biz
// name.first = ^bi
const filters = filter(r, {
email__icontains: '.biz'
, name__first__istartswith: 'bi'
})
// same as
const opts = qs.parse('email__contains=.biz&name__first__istartswith=bi')
const filters = filter(r, opts)
r.table('users').filter(filters).then((results) => {
console.log(results)
})
<rethinkdbdash>
, table <String>
[,options] <Object>
): Promisereturns a paginated list of records suitable for an api response directly from the database
<number>
[25] the maximum number of records to return<number>
[0] The number of records to skip over[string]
The filed and direction (-/+
) to sort the records by[string]
the name of the index to use to sort by - it should include the fieldconst toResponse = require('@allstar/reql-builder')
const r = require('rethinkdbdash')({db: 'test'})
toResponse(r, 'users', {
orderby: '-id'
, orderby_index: 'user_id_idx'
, limit: 5
, offset: 5 // page 2
, filters: {email__iendswith: '.biz'}
})
.then(console.log)
{
"meta": {
total: 7
, limit: 5
, offset: 5
, next: null
, previous: null
}
, "data" :[
{id: 6, email: 'fake-6@test.biz'}
, {id: 7, email: 'fake-7@test.biz'}
]
}
FAQs
Dynamic filter builder for rethinkdb and reql
The npm package @allstar/reql-builder receives a total of 2 weekly downloads. As such, @allstar/reql-builder popularity was classified as not popular.
We found that @allstar/reql-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.