Dynamic columns in mongodb view

Asked

Viewed 81 times

0

Hello,

I have a job where I need to create a view a db widget, but some columns of this view should be calculated at runtime, similar to mysql NOW(), for example: When I find in the view, I need a column to come with the current date.

I tried creating the view by setting a field with the value

{"meucampo": new Date()}

The more Mongo executes the date and saves only the fixed result and when I will consult the column meucampo it simply shows the date of when I created the rsrs view

If you can help me please

Thank you

1 answer

0

You can do this in the application, the closest that mongodb has in this sense is the $currentDate.

I hope it helps. If you need something more, glue a snippet of the application code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.