在Ektorp api中,是否可以在不知道其唯一ID值的情况下识别文档?

时间:2019-06-03 17:17:01

标签: ektorp

Ektorp api是否允许在不知道其couchdb映射了文档id的{​​{1}}的情况下,通过无SQL数据库_id搜索+查找+返回文档?阅读其api文档后,我不确定是否有可能。

我要完成的任务是能够识别一个文件(可能是_id?),而该文件的宠物名称为bird,而无需事先知道其_id

{
  "_id": "12345",
  "_rev": "5-abcdffff133432432",
  "version": "someversion",
  "doctype": "foodocument",
  "name": "foo",
  "pet": "bird"
}

如果我事先知道_id,那么下面的静态Web服务中的测试方法将查找/返回宠物的名称。

@GET
@Path("/finddocument")
public Response findDocument(@QueryParam("id") String _id) {
    CouchDbConnector db = ...;
    JsonNode doc db.get(JsonNode.class,_id);
    JsonNode pet= doc.findPath("pet");
    return Response.status(Response.Status.OK).entity(pet).build();
}

0 个答案:

没有答案