Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. {"foo" : "abc-123", more fields.... }
  2. {"foo" : "abc-456", more fields.... }
  3. {"foo" : "cde-000", more fields.... }
  4. {"foo" : "cde-555", more fields.... }
  5. {"foo" : "else-9991234", more fields.... }
  6.  
  7. {
  8. "abc": 2,
  9. "cde": 2,
  10. "else": 1
  11. }
  12.  
  13. myColl.aggregate([
  14. $project: { firstPart: { ???? '$foo'
  15.  
  16. db.collection.find().forEach(function(el){
  17. // here split your el['foo'] and update the el with new `foo1` which will have your first part
  18. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement