开发者

How do you partially-match IDs in CouchDB?

I have a set of ACLs in Couch and I want to create a view that matches applicable ones. So, given the data:

[
  {
    "_id": "/protected",
    "type": "valid-user"
  },
  {
    "_id": "/protected/group1",
    "type": "require group group1"
  },
  {
    "_id": "/protected/group1/public",
    "type": "public"
  },
  {
    "_id": "/protected/group2",
    "type": "require group group2"
  },
  {
    "_id": "/admin",
    "type": "require user admin"
  }
]

I'd like to create a view that'd allow me to pass in a string and have it find the "best" (that is to say the longest) match.

The best I've been able to do is to create a view t开发者_StackOverflow中文版hat returns the ID split into an array and then spam queries trimming the last element off until I get a match. Surely there's a way to do this on the server side ...


You could create a list function to accomplish that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜