StringBuilder sb = new StringBuilder();
Database db = Factory.getSession().getCurrentDatabase();
Document doc = db.createDocument();
doc.put("FirstName", "Aaron");
doc.put("LastName", "Monroe");
View view = db.getView("AllContacts");
ArrayList<String> key = new ArrayList<String>();
key.add(doc.getItemValueString("FirstName"));
key.add(doc.getItemValueString("LastName"));
if (view.checkUnique(key, doc)) {
sb.append("No document yet exists with name Aaron Monroe");
} else {
sb.append("Document already exists with name Aaron Monroe");
}
ExtLibUtil.getViewScope().put("javaTest", sb.toString());