rethinkdb / rethinkdb-java

Official RethinkDB Java client
https://rethinkdb.com/api/java/
Apache License 2.0
21 stars 10 forks source link

feat: WriteOperation POJO to store results of CRUDs #69

Open vinceh121 opened 1 year ago

vinceh121 commented 1 year ago

Reason for the change Issue #18 check box "TableOperation" Notably, the ability for applications to read the generated_keys attribute on inserts is essential.

Description Creates the WriteOperation and Change POJOs that contain results of the 4 CRUD commands. The issue specified a POJO also used for the result of the sync command, but as its schema is totally different, WriteOperation only works for CRUD commands.

Code examples

Connection con = r.connection().connect();

Map<String, Object> map = new HashMap<>();
map.put("value", Math.random());

Result<WriteOperation> res = r.table("test")
        .insert(map)
        .run(con, WriteOperation.class);
System.out.println(res.single());

WriteOperation{generatedKeys=[3ee14074-c36b-4ecb-b3f5-c8f2186eec73], changes=[], inserted=1, replaced=0, unchanged=0, deleted=0, skipped=0, errors=0, firstError=null, warnings=null}

Checklist

References Reference pages of the insert, update, delete and replace commands.