FAQ
With a new version of the app I'm writing, I am shifting the underlying
structure of my collection to break out some of the data currently
contained in an array to a separate collection within mongo. I'm writing
a routine using mongoose to migrate this data to the newly desired format
but I'm running into issues with trying to remove the old field/property
from the entries within the original collection. Is there anything special
I should be doing to accomplish this? My first attempt was do a simple
javascript delete on the property and then save, but the property would not
go away. I thought this might be due to the fact that the field was
defined in the schema (I need it in the schema so I can retrieve the value
to migrate to a different collection). I then created a new schema and
model that pointed to the same collection within mongo, but that doesn't
seem to work either, it appears as if mongoose thinks the field is still
there since the collection name specified in the model is the same. I'm at
a loss of how to change this schema so any suggestions would be greatly
appreciated.

--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoose-orm@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en

Search Discussions

  • Aaron Heckmann at Mar 30, 2012 at 5:01 pm
    mongoose "plays nice" with existing data in the db, not deleting it unless
    you tell it to.

    deleting the property would work if mongoose was able to hook into that
    even but alas it cannot. however you can completely remove the property
    from your document by setting the values to undefined which will trigger an
    $unset.

    doc.path = undefined;
    doc.save()
    On Fri, Mar 30, 2012 at 9:40 AM, Chris wrote:

    With a new version of the app I'm writing, I am shifting the underlying
    structure of my collection to break out some of the data currently
    contained in an array to a separate collection within mongo. I'm writing
    a routine using mongoose to migrate this data to the newly desired format
    but I'm running into issues with trying to remove the old field/property
    from the entries within the original collection. Is there anything special
    I should be doing to accomplish this? My first attempt was do a simple
    javascript delete on the property and then save, but the property would not
    go away. I thought this might be due to the fact that the field was
    defined in the schema (I need it in the schema so I can retrieve the value
    to migrate to a different collection). I then created a new schema and
    model that pointed to the same collection within mongo, but that doesn't
    seem to work either, it appears as if mongoose thinks the field is still
    there since the collection name specified in the model is the same. I'm at
    a loss of how to change this schema so any suggestions would be greatly
    appreciated.

    --
    http://mongoosejs.com
    http://github.com/learnboost/mongoose
    You received this message because you are subscribed to the Google
    Groups "Mongoose Node.JS ORM" group.
    To post to this group, send email to mongoose-orm@googlegroups.com
    To unsubscribe from this group, send email to
    mongoose-orm+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/mongoose-orm?hl=en


    --
    Aaron
    @aaronheckmann <https://twitter.com/#!/aaronheckmann>

    --
    http://mongoosejs.com
    http://github.com/learnboost/mongoose
    You received this message because you are subscribed to the Google
    Groups "Mongoose Node.JS ORM" group.
    To post to this group, send email to mongoose-orm@googlegroups.com
    To unsubscribe from this group, send email to
    mongoose-orm+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/mongoose-orm?hl=en
  • Chris at Mar 30, 2012 at 7:34 pm
    Thanks! That did the trick.

    --
    http://mongoosejs.com
    http://github.com/learnboost/mongoose
    You received this message because you are subscribed to the Google
    Groups "Mongoose Node.JS ORM" group.
    To post to this group, send email to mongoose-orm@googlegroups.com
    To unsubscribe from this group, send email to
    mongoose-orm+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/mongoose-orm?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmongoose-orm @
categoriesmongodb, nodejs
postedMar 30, '12 at 1:41p
activeMar 30, '12 at 7:34p
posts3
users2
websitemongoosejs.com
irc#mongoosejs

2 users in discussion

Chris: 2 posts Aaron Heckmann: 1 post

People

Translate

site design / logo © 2019 Grokbase