Skip to content

markselby/node-structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

structures Build Status Dependencies Status

Create data structures from SQL queries, especially useful for building API's

Getting Started

Install with: npm install structures

Examples

var Structure = require('structures');

var myStructure = {
  source: person.list,
  children: {
    addresses: {
      source: person.addresses,
      key: 'person_id',
      parent_key: 'id'
    }
  }
}

new Structure(myStructure, { id: 1,2,3,4 })
  .on('done', function (structure) { console.log(structure); })
  .on('error', function (err) { console.log(err); })
  .init();

person.list and person.addresses should be functions which return a database query suitable for use with node-postgres / any-db.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

License

Copyright (c) 2013 Mark Selby
Licensed under the MIT license.

About

Create API data structures from database queries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published