SocketStream Resource
A library to simplify adding CRUD to your SocketStream applications. Currently supports MongoDB through Mongoose.
Install
npm install socketstream-resource
Usage
Say you've got a config/db.coffee file that looks like this:
global.mongoose = require 'mongoose'mongooseconnect "mongodb://localhost/socketstream_resource_test"global.Schema = mongooseSchemaglobal.ObjectId = SchemaObjectIdglobal.Products =name: Stringglobal.Product = mongoosemodel 'Product'Products
Create a file named app/server/realm.coffee, and provide the following line:
resource = require 'socketstream-resource'exports.actions = resourceadd Product
This now gives the SS.server.realm object the following actions:
- get
- getById
- create
- update
- remove
I'm going to provide some nice-looking API documentation for this later, but for now, I advise you to take a peek at the spec/api.spec.coffee file to see how it's used, and what you can expect to get back.