Closed accateo closed 5 years ago
Hi, after different hours of research, I found how to make a find.toArray with projection:
msg.payload = [{timestamp: {$gt: date_from.getTime() , $lt: date_to.getTime() }},{"fields": { "name": 1,timestamp:1}}]
Now the problem is, if I want to substitute "name" with a variable? How can I do? I tried:
msg.payload = [{timestamp: {$gt: date_from.getTime() , $lt: date_to.getTime() }},{"fields": { var: 1,timestamp:1}}]
but it doesn't work. Any idea?
Thanks
Solution in ES6:
msg.payload = [{timestamp: {$gt: date_from.getTime() , $lt: date_to.getTime() }},{"fields": { [var]: 1,timestamp:1}}]
Hi, after different hours of research, I found how to make a find.toArray with projection:
msg.payload = [{timestamp: {$gt: date_from.getTime() , $lt: date_to.getTime() }},{"fields": { "name": 1,timestamp:1}}]
Now the problem is, if I want to substitute "name" with a variable? How can I do? I tried:
msg.payload = [{timestamp: {$gt: date_from.getTime() , $lt: date_to.getTime() }},{"fields": { var: 1,timestamp:1}}]
but it doesn't work. Any idea?
Thanks