aleclarson
aleclarson

Reputation: 19035

Replace a nested object with another object

I want to replace a nested object with another object.

Is this the simplest way to express that?

r.expr({ foo: {bar: 1}, eck: true })
 .merge({ foo: null }, { foo: {zim: 1} })

// Expected output: { foo: {zim: 1}, eck: true }

Upvotes: 1

Views: 71

Answers (1)

aleclarson
aleclarson

Reputation: 19035

You can use r.literal for this: https://www.rethinkdb.com/api/javascript/literal

r.expr({ foo: {bar: 1}, eck: true })
 .merge({ foo: r.literal({zim: 1}) })

Upvotes: 2

Related Questions