Skip to content

Commit fb7f921

Browse files
createView
Creates a view as the result of the applying the specified aggregation pipeline to the source collection or view.
1 parent 36e1455 commit fb7f921

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mongodb-commands.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,25 @@ db.restaurants.dropIndex("cuisine_1_grades.score_1")
291291
{ "nIndexesWas" : 4, "ok" : 1 }
292292
```
293293

294+
### CreateView
295+
Syntax
296+
```js
297+
db.createView(<view>, <source>, <pipeline>, <options>)
298+
```
299+
300+
Example
301+
```js
302+
db.createView('postsTitles', 'posts',[{$project:{title:1}}]);
303+
{ "ok" : 1 }
304+
305+
306+
db.postsTitles.find();
307+
```
308+
309+
310+
311+
294312
<div align="right">
295313
<b><a href="#">↥ back to top</a></b>
296314
</div>
315+

0 commit comments

Comments
 (0)