update by id loopback4 code example
Example 1: loopback upsert with where
PersistedModel.upsertWithWhere([where], data, callback)
Example 2: loopback find or create
await server.models.Role.findOrCreate(
{where: {name: val} },
{name: val}
);