Update records
Updated at:
This topic describes how to update one or more records in a client application and a cloud function.
Console operations
Log on to the EMAS Management Console. Select Serverless and then click Enter to open the Serverless console.
In the navigation pane on the left, select ApsaraDB.
On the ApsaraDB page, click the target data table.
On the Data tab, click Edit for the target record.
Client calls
Update a single record in a collection.
mpserverless.db.collection('users').updateOne({ name: 'jerry' }, { $set: { age: 10 } }) .then(res => {}) .catch(console.error);Update multiple records in a collection.
mpserverless.db.collection('users').updateMany({ name: 'jerry' }, { $set: { age: 10 } }) .then(res => {}) .catch(console.error);
Function calls
Update a single record in a collection.
'use strict'; module.exports = async function (ctx) { return await ctx.mpserverless.db.collection('users') .updateOne({ name: 'jerry' }, { $set: { age: 10 } }); };Update multiple records in a collection.
'use strict'; module.exports = async function (ctx) { return await ctx.mpserverless.db.collection('users') .updateMany({ name: 'jerry' }, { $set: { age: 10 } }); };
Is this page helpful?