Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mongoose for Application Development

You're reading from  Mongoose for Application Development

Product type Book
Published in Aug 2013
Publisher Packt
ISBN-13 9781782168195
Pages 142 pages
Edition 1st Edition
Languages
Author (1):
Simon Holmes Simon Holmes
Profile icon Simon Holmes

Table of Contents (18) Chapters

Mongoose for Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Introducing Mongoose to the Technology Stack Establishing a Database Connection Schemas and Models Interacting with Data – an Introduction Interacting with Data – Creation Interacting with Data – Reading, Querying, and Finding Interacting with Data – Updating Interacting with Data – Deleting Validating Data Complex Schemas Plugins – Re-using Code Index

Data management when modifying existing schemas


If you have taken all of the changes outlined in this chapter and added them to your application, you'll probably notice quite early that the list of projects on the user page doesn't display. This is because we have changed the schemaType of createdBy in projectSchema from String to ObjectId. If you create new projects now, they will show up in the list.

In a development environment and a prototyping scenario, like we have here, this isn't a major issue as we can just add in some more temporary test data. If you're dealing with a live environment or pre-existing data that you want to use then you have to be a bit more careful when changing a schema in this way.

There are various ways you can handle this, both on the schema side and the data management side. A possible approach is to duplicate the existing schema in its entirety and changing the SchemaTypes that you need to.

To manage the data migration you could then either create a script to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}