rethinkdb / rethinkdb/docs

Insert - conflict options with a function on nested data

Open
#1,202 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
118
Forks
161
PR merge metrics
No merged PRs in 30d

Description

r.table('table').insert({
    id: id,
    session: session,
    sockets: [{
        id: socket_id
    }]
}, {conflict: function(id, oldDoc, newDoc) {
    return newDoc.merge({
        session: session,
        sockets: sockets(oldDoc('sockets'), newDoc('sockets'))
    });
}})

Adding new objects works fine:

function sockets(oldDoc, newDoc) {
    return oldDoc.append({
        id: socket_id
   });
}

Is it possible to update / remove nested data using oldDoc object?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the insert conflict function and its oldDoc/newDoc expressions in the issue body, especially the nested sockets data. Determine whether oldDoc supports updating or removing nested values, then document the supported behavior and syntax; no repository file or test is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
databases, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.