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

router.put Set by Index not ObjectID #32

Closed
wants to merge 1 commit into from

Conversation

pehaada
Copy link

@pehaada pehaada commented Jun 13, 2014

This is my first pull request my apologies if I'm doing something incorrect. I think there was an issue in

router.put(reGet, function (req, res, next) {

When the code was running for a subdocument that was an array of sub documents. It was trying to set

tobj.set(last, body); However last was an object ID and the Mongoose code would bomb out

MongooseArray.prototype.set = function set (i, val) {
this[i] = this._cast(val);
this._markModified(i);
return this;

I made a change that would search the subdocument and figure out the correct index based on the object ID passed in from the route.

@jspears
Copy link
Owner

jspears commented Jun 13, 2014

Thanks for the pull request! I will take a look this weekend, I swear that
bit of code has bitten me like 20 different ways.

On Fri, Jun 13, 2014 at 1:34 PM, pehaada notifications@github.com wrote:

This is my first pull request my apologies if I'm doing something
incorrect. I think there was an issue in

router.put(reGet, function (req, res, next) {

When the code was running for a subdocument that was an array of sub
documents. It was trying to set

tobj.set(last, body); However last was an object ID and the Mongoose code

would bomb out

You can merge this Pull Request by running

git pull https://github.com/pehaada/mers master

Or view, comment on, or merge it at:

#32
Commit Summary

  • Put Allow Arrays by index

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#32.

@jspears
Copy link
Owner

jspears commented Jun 15, 2014

Hrm does npm test pass for you?
These are failing after the merge.
routes testing /rest/blogpost put comments[1] to the blogpost:
routes update a nested array put should update a nested array:

@pehaada
Copy link
Author

pehaada commented Jun 25, 2014

I ended up reverting my change and pulling the latest code out of github. When I run the test on the github version I'm also seeing some of the test fail. Sorry for all the questions I'm new to using Mocha but learning a lot by running the tests :)

I assume on your current version the test are all passing?

On Commit 6afee24 I'm getting the following errors:

image

@jspears jspears closed this Mar 23, 2015
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

Successfully merging this pull request may close these issues.

2 participants