Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- var PostsOfTheWeekSchema = new mongoose.Schema({
- sunday: {
- posts: [{}],
- date: Date
- },
- monday: {
- posts: [{}],
- date: Date
- },
- tuesday: {
- posts: [{}],
- date: Date
- },
- wednesday: {
- posts: [{}],
- date: Date
- },
- thursday: {
- posts: [{}],
- date: Date
- },
- friday: {
- posts: [{}],
- date: Date
- },
- saturday: {
- posts: [{}],
- date: Date
- },
- });
- module.exports = mongoose.model('PostsOfTheWeek', PostsOfTheWeekSchema);
- router.get('/postsOfTheDay', function (req, res, next) {
- PostsOfTheWeek.find({}).populate({path: 'posts', populate: {path: 'post', model: 'Post'}}).exec(function (err, posts) {
- if (err) { return next(err); }
- res.json(posts);
- });
- });
- {
- "_id": "599a5a529f5cee12bbeb7737",
- "__v": 0,
- "saturday": {
- "posts": [],
- },
- "friday": {
- "posts": [],
- },
- "thursday": {
- "posts": [],
- },
- "wednesday": {
- "posts": [],
- },
- "tuesday": {
- "posts": [],
- },
- "monday": {
- "posts": [],
- },
- "sunday": {
- "date": "2017-08-21T03:58:10.000Z",
- "posts": [
- {
- "name": "Music",
- "post": "599a298f5bdc6e107a8a5a48"
- },
- {
- "name": "News",
- "post": "599a134189c3150fe701d384"
- }
- ],
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement