| |
read source history
= createView() =
----
[[MongoDB Driver Function Reference]]
Creates a view.
More information can be found in the corresponding entry of the [[https://docs.mongodb.com/manual/reference/method/db.createView/index.html|MongoDB Manual]].
[[[@cG
db.createView(<name>, <source>, <pipeline>[, <options>])
]]]
**Arguments**
[[[@w
|@t0@r0@c0 <name> | | View name. |
| <source> | | Source collection. |
| <pipeline> | | An array of BSON documents specifying the [[https://docs.mongodb.com/manual/core/aggregation-pipeline/#id1|aggregation pipline]] for the view. |
| <options> | | A BOSN document specifying options. |
]]]
**Options**
[[[@cw
{ capped: collation: <document> }
<<@f:text>>
|@t0@r0@c0 collation| | A document specifying the [[https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#collation|collation]]. |
<<@/f>>
]]]
**Example**
[[[@cw
db.createView("bosses", "employees", [{ $match: {salary: { $gt: 1000000 }}}]);
]]]
Creates a view on the employees collection containing .
----
[[Main|home]] | [[MongoDB Driver Function Reference]] | [[MongoDB Driver]]
|