根据
ColumnConfig
const col = {
name: 'added_at',
def: () => new Date() // default to the current Date/Time
};
const cs = pgp.helpers.ColumnSet(['firstname', 'lastname', 'email', col], { table: 'customer' });
或者,您可以用多种其他方式定义它,如
ColumnConfig
非常灵活。
例子:
const col = {
name: 'added_at',
mod: ':raw', // use raw-text modifier, to inject the string directly
def: 'now()' // use now() for the column
};
或者,您可以使用属性
init
const col = {
name: 'added_at',
mod: ':raw', // use raw-text modifier, to inject the string directly
init: () => {
return 'now()';
}
};
看
ColumnConfig
有关详细信息,请参阅语法。
P、 我是
pg-promise
.