qrry

0.0.3 • Public • Published

qrry

Modular hierarchical data querying

Build Status Code Quality Code Coverage NPM Version

wtf?

This module allows you to define a tree-shaped structure that holds all accessible data, and query the data at different levels. By using on-demand resolvers (just functions, really), only the requested data will be computed.

Example

const qrry = require('qrry');
const {byKey} = qrry;
const Post = require('./models/Post');
 
const $ = qrry({
    me: {
        posts: byKey('slug')(({userId}, {path}) => {
            
            return path.length ? Post.find({userId, slug: path[0]}) : Post.find({userId});
        }),
    },
});
 
$('/me/posts', {userId: 1}).then(console.log);
 
// {me: { 
//    posts: {
//       coolPost: {userId: 1, slug: "coolPost", id: 100, content: "..."}
//    }
// }
 

Install

$ npm install qrry

License

MIT © sgtlambda

dependency Status devDependency Status

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i qrry

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • jmversteeg