2014-07-07 136 views
0
collections: 
    posts: -> 
     # @getCollection('documents').findAllLive({relativeDirPath: 'posts'}, [date: -1]) 
     @getCollection('documents').findAllLive({relativeDirPath: {'$in' : ['posts', /post\/[0-9]+/ ]}}, [date: -1]) 

在主要​​,{relativeDirPath: {'$in' : ['posts']}是标准的事情。如何使用模式匹配获取路径中的集合?

但是,{relativeDirPath: {'$in' : ['posts', /post\/[0-9]+/ ]}没有。

我试图让那些在下面的目录结构添加到收藏posts文件:

/src/documents/posts/blah-blah.html 
/src/documents/post/12345678/foo-bar-baz.html 
/src/documents/post/62347878/woop-woop.html 

...和使用模式在relativeDirPath匹配似乎是要走的路。 但是,它不匹配任何这些文件。 我该如何做这项工作?

回答

0

根据要求,您不需要模式匹配。组查询键“$或”应该适合你:

@getCollection('documents').findAllLive 
    $or: [ 
      { 
       relativeDirPath: 
        "$startsWith": "posts" 
      } 
      { 
       relativeDirPath: 
        "$startsWith": "post" 
      } 
     ] 
, [date: -1] 
相关问题