Hello! Full disclosure, I am very new to backend tech and I am building an Animal Crossing Critterpedia to further learn and solidify my knowledge of Node, Express, Mongo, & Mongoose.To start the project, I made a short script to make schemas and pull the JSON file from the animal crossing API and push the data to the database. I ended up with a ‘Critterpedia’ database with 3 collections: ‘Fish,’ ‘Bugs,’ and ‘Sea Creatures.’The collections are objects that have a key/value array that contains up to 12 numbers, one for each month of the year that the critter is available.Long story short, I am looking to filter through each of the collections, and filter through those arrays, to display which critters are new this month and which ones will be leaving this month.Fish.find({},(err, fish) => { if (err) { return handleErr(err); } else { res.render(‘index’, { fish : fish }); } }); (this syntax may have punctuation errors)I know that the above sends all the fish data to the template, but how would I loop through all 3 collections (fish, bugs, sea) AND the arrays inside to return only critters available in month 7.I’ve got a few variables like Date.getMonth() I just need to compare them and can’t figure it out.Any help would be highly appreciated!
Submitted July 22, 2020 at 02:02AM by Furry_pizza
No comments:
Post a Comment