javascript - Mongo: How to return a cursor with partial value match? -


i have collection posts , each post has title , author.

posts : {     id     : 7867887687,     title  : unnamed-1,     author : joe  },{     id     : 2867887687,     title  : unnamed-2,     author : joe  },{     id     : 1867337687,     title  : happyhour,     author : joe  },{     id     : 2367337687,     title  : crappyhour,     author : deb  } 

i want return cursor posts joe have title unnamed*. next step sort unnamed posts , add new unnamed post next available -x number. (if 1 had been deleted next available -x might in middle of others ... (sort of creaiting new folders in windows))

how in mongo?

or should return posts joe , foreach find unnamed ones somehow?

or other method?

use regular expression:

db.posts.find({author:'joe', title:/^unnamed/i}) 

here more read http://docs.mongodb.org/manual/reference/operator/regex/#op._s_regex


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -