MongoDB Tips: Views
use <db>;
This command will give you all view definition under the db you are in.
ex:
{
"name" : "utilizationSubcategoryNumbersOMD",
"type" : "view",
"options" : {
"viewOn" : "utilizationSubcategoryNumbers",
"pipeline" : [
{
"$match" : {
"utilizationId.boardId.boardDate" : {
"$gte" : ISODate("2018-01-01T04:00:00Z")
}
}
}
]
},
"info" : {
"readOnly" : true
}
}
using this information, we can create the same view in another environment as such by following the syntax:
db.createView(<view>, <source>, <pipeline>, <options>)
db.createView("utilizationSubcategoryNumbersOMD",
"utilizationSubcategoryNumbers",
[{
"$match" : {
"utilizationId.boardId.boardDate" : {
"$gte" : ISODate("2018-01-01T04:00:00Z")
}
}
}
])
Ref: https://docs.mongodb.com/manual/reference/method/db.createView/
Ref: https://docs.mongodb.com/manual/reference/method/db.createView/
Comments
Post a Comment