Super simple implementation of OData server running on Node.js with easy adapters for mongodb and nedb. Just define an OData model, provide a mongo or nedb database, hook into node.js http server and run.
It supports basic operations you would expect like providing $metadata, filtering and also operations for insert, update and delete. On the other hand it suppose to be really simple so you don't get support for entity links, batch operations, atom feeds and many others.
The implementation is tested with .net OData client and it should fulfill basic protocol requirements.
This is how you can create an OData server with node.js http module and nedb.
var http = ;var Datastore = ;var db = inMemoryOnly: true ;var ODataServer = ;var model =namespace: "jsreport"entityTypes:"UserType":"_id": "type": "Edm.String" key: true"test": "type": "Edm.String"entitySets:"users":entityType: "jsreport.UserType";var odataServer =;http;
Now you can try requests like:
GET http://localhost:1337/users?$filter=test eq 'a' or test eq 'b'&$skip=1&$take=5
GET http://localhost:1337/users?$orderby=test desc
POST, PATCH, DELETE
It works the same way with nedb and mongo. You just need to provide callback for mongo database instance.
It works well also with the express.js. You even don't need to provide service uri in the
ODataServer constructor because it is taken from the express.js request.
onMongo is just a simple way for initializing
ODataServer. You can implement your own data layer or override default behavior using following methods:
odataServer;//add hook to error which you can handle or pass to default
I will maintain this repository for a while because I use it in jsreport. You are more than welcome to contribute with pull requests and add other basic operations you require.