vjsrinath / sails-orientdb

An waterline adapter for orient db

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sails Create Controller Issue

jeswinjames24 opened this issue · comments

I tried to use the information from the git repo and tried to create an application and failed to do so.

Possibly unhandled TypeError: Converting circular structure to JSON
at Object.stringify (native)
at ServerResponse.res.json (/home/action/.parts/lib/node_modules/sails/node_modules/express/lib/response.js:189:19)
at /home/action/sa/api/controllers/UserController.js:17:13
at /home/action/.parts/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:219:9
at /home/action/.parts/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:157:25
at null. (/home/action/.parts/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:151:44)
at fn (/home/action/.parts/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:60:10)
at iterate (/home/action/.parts/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:149:13)
at Object.async.eachSeries (/home/action/.parts/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:165:9)
at Object.runner.afterCreate (/home/action/.parts/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/callbacksRunner.js:63:9)

Controller:

module.exports = {
create: function(req, res){
var params = req.params.all();
User.create(params,{"@class":"User"}, function(err, result){
if (err) return next(err);
res.status(201);
res.json(User);
});
}
};

Kindly assist.

You are trying to return the User collection object. it must be

res.json(result);