Browse Source

feat: formula - add created_at/updated_at column - WIP

pull/7019/head
Pranav C 12 months ago
parent
commit
9ac662c2c4
  1. 34
      packages/nocodb/src/db/functionMappings/commonFns.ts

34
packages/nocodb/src/db/functionMappings/commonFns.ts

@ -151,4 +151,38 @@ export default {
),
};
},
CREATED_AT: async (args: MapFnArgs) => {
const createdAtCol = args.model?.columns?.find(
(col) => col.column_name === 'created_at',
);
if (!createdAtCol) {
NcError.badRequest('Created at field not found');
}
return {
builder: args.knex.raw(
`${
(await args.fn({ type: 'Identifier', name: createdAtCol.id }, args.a))
.builder
} ${args.colAlias}`,
),
};
},
UPDATED_AT: async (args: MapFnArgs) => {
const createdAtCol = args.model?.columns?.find(
(col) => col.column_name === 'updated_at',
);
if (!createdAtCol) {
NcError.badRequest('Created at field not found');
}
return {
builder: args.knex.raw(
`${
(await args.fn({ type: 'Identifier', name: createdAtCol.id }, args.a))
.builder
} ${args.colAlias}`,
),
};
},
};

Loading…
Cancel
Save