Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
JSON AST to RethinkDB query
npm install --save mr.q
// Sample data
r.table('mr').insert([
{
id: 1,
type: 'foo',
name: 'foo1',
value: 1,
list: [],
dt: new Date('2014-08-17 12:00:00')
}, {
id: 2,
type: 'foo',
name: 'foo2',
value: 2,
list: ['A'],
dt: new Date('2014-08-17 13:00:00')
}, {
id: 3,
type: 'foo',
name: 'foo3',
value: 3,
list: ['A', 'B'],
dt: new Date('2014-08-17 14:00:00')
}, {
id: 4,
type: 'bar',
name: 'bar1',
value: 1,
list: ['A', 'C'],
dt: new Date('2014-08-17 12:00:00')
}, {
id: 5,
type: 'bar',
name: 'bar2',
value: 2,
list: ['B', 'C'],
dt: new Date('2014-08-17 13:00:00')
}
]);
var r = require('rethinkdb');
var mr = require('mr.q');
var co = require('co');
co(function*() {
// documents that have type of 'foo' and name in ['foo1', 'bar1']
var query = mr.match({
type: 'foo',
name: {
$in: ['foo1', 'bar1']
}
});
var result = yield run(query(table));
// {
// id: 1,
// type: 'foo',
// name: 'foo1',
// value: 1,
// list: [],
// dt: new Date('2014-08-17 12:00:00')
// }
})();
co(function*() {
// Distinct types of documents that have type in ['foo', 'bar']
// and dt between '2014-08-17 12:00:00' and '2014-08-17 13:30:00'
var q1 = mr.match({
type: {
$in: ['foo', 'bar']
},
dt: {
$between: [
{
$date: '2014-08-17 12:00:00'
}, {
$date: '2014-08-17 13:30:00'
}
]
}
});
var q2 = mr.aggregate({
$distinct: 'type'
});
var result = yield run(q2(q1(table)));
// [
// {type: 'foo'},
// {type: 'bar'}
// ]
})();
more examples can be found in the test suite
FAQs
JSON AST to RethinkDB query
The npm package mr.q receives a total of 2 weekly downloads. As such, mr.q popularity was classified as not popular.
We found that mr.q 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.