node-restful icon indicating copy to clipboard operation
node-restful copied to clipboard

Accept schemaless

Open DaBlitzStein opened this issue 11 years ago • 2 comments

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 }

DaBlitzStein avatar Jul 18 '14 00:07 DaBlitzStein

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.

adyba avatar Sep 23 '14 18:09 adyba

It doesn't work for me @adyba

cm45t3r avatar Dec 29 '14 20:12 cm45t3r