Here is a code that i use with moongose and mongo db, i don't know where
should be your error, maybe with the parameters of middleware functions.

exports.newUser = function(request, response) {
console.log(request.body);        var user = new User({
"fullname": request.body.fullname,            "cpfcnpj":
request.body.cpfcnpj,            "email": request.body.email,
  "phone": request.body.phone,            "login": request.body.login,
           "password": request.body.password        });
user.save(function(error) {            if (error)
response.status(500).send(error);            else
response.status(200).send("user registered");        });    };


On 28 May 2017 at 21:00, vain glories <[email protected]> wrote:

> I've been using this middleware for sometime, then suddenly it stops
> working.
>
> var body = req.body;
> new ordersModel (body).save(function(err, newOrder, rowCount) {
>       if (err) throw err;
>       console.log(rowCount) // logs 1
>
>       updateEstimatedTime(newOrder); /* this function runs but inside
>    it, trying to find this same document returns null,
>    meaning it was never saved */
> });
>
> If I try something like
>
> var pleaseWork = new ordersModel (body);console.log(pleaseWork) // dumps a 
> loaded mongoose object
> pleaseWork.save(function(err, newOrder, rowCount) {
>
> So why doesn't it get persisted? I also tried reloading the server several
> times with this at the top just in case
>
> ordersModel.find({}, 'customer', function (err, docs) {
>       if (err) throw err;
>       console.log(docs)
> })
>
> But it just returns the documents that existed before this fault began.
> I've triple checked the model name, it's the same all over the script. What
> could the code be lacking?
> I have seen some examples also that suggested something in the region of
>
> var pleaseWork = new ordersModel ();
> pleaseWork.foo = body.foo;
> pleaseWork.bar = body.bar;
> pleaseWork.john = body.john;
> console.log(pleaseWork) // dumps a loaded mongoose object
> pleaseWork.save(function(err, newOrder, rowCount) {
>
> Now, this is not feasible for me; the ordersModel table has more than 10
> columns-- dropping the body object in the model's constructor is sane
> enough and worked the last time the program was run.
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules: https://gist.github.com/othiym23/9886289#file-
> moderation-policy-md
> Old group rules: https://github.com/joyent/node/wiki/Mailing-List-
> Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/nodejs/2f73dad3-4cfa-432c-9f0d-82b9da71da52%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/2f73dad3-4cfa-432c-9f0d-82b9da71da52%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
[]'s

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAET7tnbnQxP3mUaW-6ipdpUEv%2BQCHn036QMTSUVGJSq6Xihnuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to