Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Data Not Saving #24

Closed
giodamelio opened this issue Dec 11, 2013 · 3 comments
Closed

Post Data Not Saving #24

giodamelio opened this issue Dec 11, 2013 · 3 comments

Comments

@giodamelio
Copy link

I have a simple mers app.

express = require "express"
mongoose = require "mongoose"
mers = require "mers"

app = express()

Schema = mongoose.Schema

BookSchema = new Schema
    title: String
    author: String

Book = mongoose.model "Book", BookSchema

app.use "/rest", mers(
    uri: "mongodb://localhost/library"
    mongoose: mongoose
).rest()

console.log app.routes

app.listen 3141

When I post data with curl.

curl -X POST -d '{"title": "Ready Player One","author": "Ernest Cline"}' -H "Content-Type: application/json" http://localhost:3141/rest/book

It creates an empty object.

{
    "payload": {
        "__v": 0,
        "_id": "52a7fb5667c42afe7e000007"
    },
    "status": 0
}

The same thing happens with PUT. Am I doing something wrong?

@jspears
Copy link
Owner

jspears commented Dec 12, 2013

It looks right, I think I may have had a bad merge. I will take a look
and let you know.

On Wed, Dec 11, 2013 at 12:44 AM, giodamelio notifications@github.comwrote:

I have a simple mers app.

express = require "express"
mongoose = require "mongoose"
mers = require "mers"

app = express()

Schema = mongoose.Schema

BookSchema = new Schema
title: String
author: String

Book = mongoose.model "Book", BookSchema

app.use "/rest", mers(
uri: "mongodb://localhost/library"
mongoose: mongoose
).rest()

console.log app.routes

app.listen 3141

When I post data with curl.

curl -X POST -d '{"title": "Ready Player One","author": "Ernest Cline"}' -H "Content-Type: application/json" http://localhost:3141/rest/book

It creates an empty object.

{
"payload": {
"__v": 0,
"_id": "52a7fb5667c42afe7e000007"
},
"status": 0
}

The same thing happens with PUT. Am I doing something wrong?


Reply to this email directly or view it on GitHubhttps://github.com//issues/24
.

@giodamelio
Copy link
Author

Thanks

On Wed, Dec 11, 2013 at 8:11 PM, Justin notifications@github.com wrote:

It looks right, I think I may have had a bad merge. I will take a look
and let you know.

On Wed, Dec 11, 2013 at 12:44 AM, giodamelio notifications@github.comwrote:

I have a simple mers app.

express = require "express"
mongoose = require "mongoose"
mers = require "mers"

app = express()

Schema = mongoose.Schema

BookSchema = new Schema
title: String
author: String

Book = mongoose.model "Book", BookSchema

app.use "/rest", mers(
uri: "mongodb://localhost/library"
mongoose: mongoose
).rest()

console.log app.routes

app.listen 3141

When I post data with curl.

curl -X POST -d '{"title": "Ready Player One","author": "Ernest Cline"}'
-H "Content-Type: application/json" http://localhost:3141/rest/book

It creates an empty object.

{
"payload": {
"__v": 0,
"_id": "52a7fb5667c42afe7e000007"
},
"status": 0
}

The same thing happens with PUT. Am I doing something wrong?


Reply to this email directly or view it on GitHub<
https://github.com/jspears/mers/issues/24>
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-30388128
.

Gio d'Amelio
giodamelio@gmail.com

@jspears
Copy link
Owner

jspears commented May 19, 2014

app.use "/rest", mers(
uri: "mongodb://localhost/library"
mongoose: mongoose
).rest()

I do not know if this would work. its an or, use uri or mongoose. If you pass in a mongoose object or connection you will need to call connect

@jspears jspears closed this as completed May 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants