Use this handler in a POST route with validated email and name parameters.
async function handler(state) {
var { email, name } = state.req.body.params
var result = await state.plugins.mongodb
.collection('users')
.updateOne({ email }, { $set: { name } })
return state.jarpc({ ok: true, updated: result.modifiedCount })
}
modifiedCount reports how many documents changed. Use a route schema to require the input fields.
Next: Delete →