Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ { _id:
- { id: 59d0e3f728150e39b008013f,
- firstName: 'pera',
- lastName: 'pekko',
- phone: '04040404040',
- massageType: 'jipii massage',
- time: 45,
- price: 30,
- startsAt: '2017-10-02T11:00:00+03:00',
- endsAt: '2017-10-02T11:45:00+03:00' },
- email: [ 'gg@gmail.com' ],
- { _id:
- { id: 59ce25975f4d1a096cdd2733,
- firstName: 'sdad',
- lastName: 'autismus',
- phone: '04040404040',
- massageType: 'jipii massage',
- time: 60,
- price: 33,
- startsAt: '2017-10-02T12:45:00+03:00',
- endsAt: '2017-10-02T13:45:00+03:00' },
- email: [ 'YES@hotmail.com' ]
- }]
- db3.massagerTimes.aggregate(
- {$match: {_id: mongo.helper.toObjectID(data.timesData)}},
- {$unwind: "$times"},
- {$match: {"times.type": 1}},
- {
- $group: {
- _id: {
- id: "$times._id",
- firstName: "$times.firstName",
- lastName: "$times.lastName",
- phone: "$times.phone",
- massageType: "$times.massageType",
- time: "$times.time",
- price: "$times.price",
- startsAt: "$times.startsAt",
- endsAt: "$times.endsAt"
- },
- email: {$addToSet: "$times.email"},
- count: {"$sum": 1}
- }
- },
- {
- $match: {
- count: {"$lte": 1}
- }
- },
- {$sort: {"times._id": -1}},
- function (err, result) {
- if (err)
- throw err;
- if (result) {
- console.log(result);
- res.json(result);
- }
- });
- }
- {
- "_id": {
- "$oid": "59ca4eb610b3be1f8499f6d5"
- },
- "times": [
- {
- "_id": {
- "$oid": "59ce274f5f4d1a096cdd2745"
- },
- "type": 0,
- "startsAt": "2017-10-02 13:30 +03:00",
- "endsAt": "2017-10-02 13:45 +03:00"
- },
- {
- "_id": {
- "$oid": "59ce274f5f4d1a096cdd2744"
- },
- "type": 0,
- "startsAt": "2017-10-02 13:15 +03:00",
- "endsAt": "2017-10-02 13:30 +03:00"
- },
- {
- "_id": {
- "$oid": "59ce28415f4d1a096cdd275b"
- },
- "title": "sdad autismus",
- "firstName": "sdad",
- "lastName": "autismus",
- "type": 1,
- "email": "YES@hotmail.com",
- "phone": "04040404040",
- "massageType": "jipii massage",
- "time": 45,
- "price": 30,
- "additionalInfo": null,
- "startsAt": "2017-10-01T08:30:00+03:00",
- "endsAt": "2017-10-01T09:15:00+03:00"
- },
- {
- "_id": {
- "$oid": "59ce28665f4d1a096cdd275e"
- },
- "title": "sdad autismus",
- "firstName": "sdad",
- "lastName": "autismus",
- "type": 1,
- "email": "YES@hotmail.com",
- "phone": "04040404040",
- "massageType": "jipii massage",
- "time": 45,
- "price": 30,
- "additionalInfo": null,
- "startsAt": "2017-10-01T09:30:00+03:00",
- "endsAt": "2017-10-01T10:15:00+03:00"
- },
- {
- "_id": {
- "$oid": "59d0e3f728150e39b008013f"
- },
- "title": "pera pekko",
- "firstName": "pera",
- "lastName": "pekko",
- "type": 1,
- "email": "gg@gmail.com",
- "phone": "04040404040",
- "massageType": "some massage",
- "time": 45,
- "price": 30,
- "additionalInfo": null,
- "startsAt": "2017-10-02T11:00:00+03:00",
- "endsAt": "2017-10-02T11:45:00+03:00"
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement