如何使用java程序将子字段提供到沙发数据库中的文档字段?

时间:2014-05-27 05:53:42

标签: java couchdb

我想以下列格式在文档中插入数据:

_id:"c0b3457b1d6e5f8431d62a31fd00073c"
Name:"priya"
Education:
       10th:"68.9%"
       12th:"62.83%"
       graduation:"69.73%
       post-graduation:"71.55%"

我希望通过编程来实现这种格式。新来的couchdb。

1 个答案:

答案 0 :(得分:0)

试试吧......

Session studentDbSession = new Session("localhost",5984);

           Database studentCouchDb = studentDbSession.getDatabase("student");

           Document newdoc = new Document();

           HashMap<String , String> properties = new HashMap<String,String>();  

           newdoc.setId("c0b3457b1d6e5f8431d62a31fd00073c");

           newdoc.put("Name", "Priya");

           properties.put("10th", "69.9");

           properties.put("12th", "62.83");

           properties.put("Graduation", "69.73");

           properties.put("Post_Graduation", "71.55");

           newdoc.put("Education", properties);

           studentCouchDb.saveDocument(newdoc);