pofider / node-simple-odata-server

Simple OData server for node.js
MIT License
97 stars 61 forks source link

TypeError: simpleOdataServer.adapter is not a function #32

Closed xjuhu closed 6 years ago

xjuhu commented 6 years ago

Tested in my own system, as well as on npm.runkit, always getting same error: TypeError: simpleOdataServer.adapter is not a function

Demo-Code from runkit:

var mongoClt = require('mongodb').MongoClient;
var simpleOdataServer = require("simple-odata-server");
var Adapter = require('simple-odata-server-mongodb');
var url = "127.0.0.1:27017";

mongoClt.connect(url, function(err, db) {
    simpleOdataServer.adapter(Adapter(function(cb) { cb(err, db); })); 
});
pofider commented 6 years ago

See the example. https://github.com/pofider/node-simple-odata-server#get-started

var odataServer = ODataServer("http://localhost:1337")
    .model(model)
    .adapter(Adapter(function(es, cb) { cb(null, db)}));
xjuhu commented 6 years ago

Sorry, got my example from your suggestion:

The mongo adapter can be used as

var Adapter = require('simple-odata-server-mongodb') MongoClient.connect(url, function(err, db) { odataServer.adapter(Adapter(function(cb) { cb(err, db.db('myodatadb')); })); });

Using mongodb, I have no model of data, because the documents stored are very different in structure and content. How to use this without a applying a model?

pofider commented 6 years ago

Unfortunately the model is required.

xjuhu commented 6 years ago

Ok, I see, this approach will not end up in a working stack for me. Thank you for your replies, anyway.