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

主要docpad.coffee{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似乎是要走的路。但是,它与这些文件中的任何一个都不匹配。我怎样才能使这项工作?

4

1 回答 1

0

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

@getCollection('documents').findAllLive
    $or: [
            {
                relativeDirPath:
                    "$startsWith": "posts"
            }
            {
                relativeDirPath:
                    "$startsWith": "post"
            }
        ]
, [date: -1]
于 2014-08-29T08:54:30.413 回答