nosql - Creating a new collection from results of a mongodb query -
i'm trying create new collection using results of mongodb query. example,
class="lang-js prettyprint-override">db.coll.find({name:'abcd'})
will homecoming subset of collection. now, want insert result new collection. how can this?
you can't straight find
, can utilize $out
pipeline stage of aggregate
it:
db.coll.aggregate([ {$match: {name: 'abcd'}}, {$out: 'newcoll'} ])
note $out
back upwards added in mongodb 2.6.
mongodb nosql
No comments:
Post a Comment