Re: AddResult getGeneratedIds is useless.
Posted by: Alexander Soklakov
Date: August 03, 2018 02:12AM

Hi lantian FU,

The getGeneratedIds() does exactly the same it's description says: "Get a list of document ids generated in the server for the documents added by collection.add()".

For example:

// document with assigned _id
String json1 = "{'_id': 'Id#1', 'name': 'assignedId'}".replaceAll("'", "\"");
// document without assigned _id
String json2 = "{'name': 'autoId'}".replaceAll("'", "\"");
// add one document with assigned _id and two documents without _id
res = this.collection.add(json2).add(json1).add(json2).execute();

List<String> ids = res.getGeneratedIds();
//gives ids == [00005b6408fc000000000000000b, 00005b6408fc000000000000000c]

I.e. _only_ generated ids are returned by this method.

Options: ReplyQuote


Subject
Written By
Posted
Re: AddResult getGeneratedIds is useless.
August 03, 2018 02:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.