I'm on react native and I'm unsure how to use prepareUpdate is it okay to do the following?
const oldChannel = await getChannel('asdf')
const prepareChannel = (x: Channel) => {
x._raw.id = 'asdf'
x.parent!.id = 'test'
}
const preparedChannel = oldChannel
? oldChannel.prepareUpdate(prepareChannel)
: channelsCollection.prepareCreate(prepareChannel)
await doSomeAsyncWork()
await database.write(() => database.batch(preparedChannel))
From the source code it says
// After preparing an update, you must execute it synchronously using
// database.batch()
Additionally at some point I'm pretty sure I got the error record.prepareUpdate was called on ${this.table}#${this.id} but wasn't sent to batch() synchronously -- this is bad!
but I'm no longer able to reproduce that error also I have no idea how I got it because I'm on react native and process.nextTick is not defined which is needed for the error to appear.