Saturday 15 April 2017

Flexible model fields using NodeJS and Mongodb

Itemname Stringmanufacturer Stringdescription StringInventoryusername { type:String, index:true}items { item: Array, quantity: Array }Hopefully that was clear enough to understand how I'd like to structure my collections. I have multiple items, of which only have names and info about them. The inventory will be specific per user, but will have more detailed information about those items that will be stored in the Items field. Though I'd like it so a user may have one item or a googleplex of items with information such as quantity, age, etc.I want it structured like this so when users add items to their inventory they may choose from a pool of previously stored items.Would I be able to store inside Inventory > items > item[] an item name from the Item collection (to later fetch an item by name for the rest of the data), and pair up information collected in a form from the user (such as a quantity) about their unique item inside Inventory > items > quantity[]To then later access it and pair them up such as:inventory.items.item[0] inventory.items.quantity[0]

Submitted April 16, 2017 at 02:21AM by JayHerlth

No comments:

Post a Comment