dreamcatcher
dreamcatcher is a tool that extends the knex-schemer and bookshelf-factory schema definition format to produce a rest web service using restify to perform CRUD operations on resources stored in a relational database. At its core, dreamcatcher uses bookshelf and knex to perform the actual database access, and bookshelf-factory to produce the models.
- See the WIKI for full documentation
- And the Change Log for what's new
Install
npm install -g dreamcatcher
Usage
// create a database connection configvar config = "client": "mysql" "connection": "host": "127.0.0.1" "user": "db" "password": "password" "database": "test" "charset": "utf8" ; // require the package passing the configvar dream = config;
Basic Example
JavaScript
// create a database connection configvar config = "client": "mysql" "connection": "host": "127.0.0.1" "user": "db" "password": "password" "database": "test" "charset": "utf8" rest: "port": 8081 ; // require the package and pass the db connection configvar dream = config;var type = dreamschemerconstantstype; // define a schema in schemer format that has been extended to use // bookshelf-factory and dreamcatcher field extensionsvar schema = survivor: id: type: typeinteger primary: true increments: true views: 'summary' name: type: typestring size: 200 views: 'summary' groups: belongsToMany: 'group' views: 'summary' station_id: type: typeinteger station: belongsTo: 'station' views: 'summary' _rest: methods: HEAD: {} GET: {} POST: {} PUT: {} DELETE: {} ; // create the routesvar routes = dream; // run the serverdream;
This will create the routes and methods
- (HEAD, GET, POST) http://host.domain.com:8081/survivors
- (HEAD, GET, PUT, DELETE) http://host.domain.com:8081/survivors/:id
Tools
Created with Nodeclipse (Eclipse Marketplace, site)
Nodeclipse is free open-source project that grows with your contributions.