Skip to main content
Version: 1.2.6

Update Query

modify/change records of table This page uses the following methods:

  • await presql.updateOne(<update>)
  • await presql.updateMany(<update>)
  • await presql.replaceOne(<update>) -Comming Soon
  • await presql.table('').updateOne(<update>) -Comming Soon

Update Single Record

Create a file at index.js:

index.js
import presql from './connection';

async function UpdateSingleData() {
const data = await presql.updateOne({
table: "users", // required parameter
data: {
firstName: "John",
lastName: "Doe",
}, //data is required parameter only single object
where:{
id:1
},// where field is optional, to update special row please pass this field
});
// if table and column uses any special character, please pass name in cammelCase e.g first_name to firstName

console.log(data); // if showResults is true, it will print results
}

Update Multiple Records

Create a file at index.js:

index.js
import presql from './connection';

async function UpdateMultipleData() {
const data = await presql.updateOne({
table: "users", // required parameter
data: [
{
firstName: "John",
lastName: "Doe",
},
{
firstName: "David",
lastName: "Olis",
},
{
firstName: "Rachna",
lastName: "Singh",
},
] , //data is required parameter only array of objects
where:{
id:1
},// where field is optional, to update special row please pass this field
});
// if table and column uses any special character, please pass name in cammelCase e.g first_name to firstName

console.log(data); // if showResults is true, it will print results
}