Guest User

Untitled

a guest
Jan 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. var catsObjectId = new Array();
  2. var data = new Array();
  3. Recipe.find((err,doc3)=> {
  4. data = doc3;
  5. for (var i = 0; i < data.length; i++) {
  6. catsObjectId.push([]);
  7. data[i]['categories'].forEach((item, index) => {
  8. Recipecat.findOne({_id: item}, (err,result)=> {
  9. item = result.name;
  10. catsObjectId.push(item);
  11. });
  12. })
  13. }
  14. console.log(catsObjectId);
  15. });
  16.  
  17. var recipeSchema = Schema({
  18. categories: [{
  19. type: Schema.Types.ObjectId,
  20. ref: 'RecipeCat',
  21. }]
  22. });
  23.  
  24. var recipecatSchema = new Schema({
  25. name: {
  26. type: String,
  27. required: true
  28. }
  29. });
  30.  
  31. catsObjectId.push([]);
Add Comment
Please, Sign In to add comment