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

Error With Status of 0 #31

Closed
VARG0S opened this issue May 28, 2014 · 3 comments
Closed

Error With Status of 0 #31

VARG0S opened this issue May 28, 2014 · 3 comments

Comments

@VARG0S
Copy link
Contributor

VARG0S commented May 28, 2014

Hello,
I am not sure what is causing this, but I have always used the status property of the Object returned from MERS to determine whether an error has occurred. I am getting an error from MongoDB about a duplicate id, (I know the this error isn't a MERS issues), but I was surprised when the object comes back from MERS with an "error" property and the status was 0. I was just curious if you had any insight into this, I know I am probably missing something obvious, but I am losing track of the code during this snippet from route.js

router.post(base + '/:type', function (req, res) {
        var Model = m(req);
        new Model(clean(req.body)).save(run(res));
    });

image

Thanks for any insight you may be able to provide

@jspears
Copy link
Owner

jspears commented Jun 2, 2014

That isn't good, I'll write a test and try to get to the bottom of it. Thanks for the info!

@jspears
Copy link
Owner

jspears commented Jun 2, 2014

I believe that is happening because the validation happens within mongo, not mongoose where most validation happens. However, I can not seem to reproduce the error.... be great if you could share part of a schema that this happens with.

@VARG0S
Copy link
Contributor Author

VARG0S commented Jun 2, 2014

I think you are exactly right. I ran across this when I changed the name of an indexed unique field in my mongoose schema. So I had the first schema and then I changed it to the second listed below. When I went to insert a new record using the new schema, it would fail because Mongo was still looking for a "Name" index in addition to the newly created "usertype_name" index, but I was only sending the required "usertype_name" field and "Name" wasn't being sent and consequently wasn't satisfying the mongo rules.

Original:
var UserTypeSchema = new Schema({
        Name: {type: String, index: { unique: true } },
        Description: {type: String }
    });
Modified:
var UserTypeSchema = new Schema({
        usertype_name: {type: String, index: { unique: true } },
        usertype_description: {type: String }
    });

@VARG0S VARG0S closed this as completed Oct 6, 2021
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