baugarten / node-restful

A library for quickly providing a REST API with express or connect
http://www.baugarten.me/node-restful/
1.31k stars 249 forks source link

Accept schemaless #65

Open DaBlitzStein opened 10 years ago

DaBlitzStein commented 10 years ago

Actually the system doesn't accept schemaless mongodb types:

var express = require('express'), restful = require('node-restful'), mongoose = restful.mongoose; var app = express();

app.use(express.bodyParser()); app.use(express.query());

mongoose.connect("mongodb://localhost:27017/schemalesstable");

var gameData = app.resource = restful.model('gameData', mongoose.Schema({ },{collection: 'gameData', strict:false})).methods(['get', 'post', 'put', 'delete']);

gameData.register(app, '/rest/gameData');

app.listen(4000);

The insertion only shows an empty document:

/* 0 */ { "_id" : ObjectId("53c862fc3e3f44ac29feee07"), "__v" : 0 }

adyba commented 10 years ago

I have had same problem (tried to POST new data or PUT changes via POSTMAN chrome extension). Make sure your header contains Content-Type: application/json pair, other than that a JSON will not be processed. As I extended my header the sample worked as expected.

cm45t3r commented 9 years ago

It doesn't work for me @adyba