2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 22:58:28 +00:00
books/backend/helpers.ts

50 lines
1007 B
TypeScript
Raw Normal View History

2022-03-31 12:48:32 +05:30
import { DatabaseMethod } from 'utils/db/types';
2022-03-25 15:42:39 +05:30
import { KnexColumnType } from './database/types';
export const sqliteTypeMap: Record<string, KnexColumnType> = {
2022-03-23 11:46:13 +05:30
AutoComplete: 'text',
Currency: 'text',
Int: 'integer',
Float: 'float',
Percent: 'float',
2022-03-25 15:42:39 +05:30
Check: 'boolean',
2022-03-23 11:46:13 +05:30
Code: 'text',
2022-03-25 15:42:39 +05:30
Date: 'date',
Datetime: 'datetime',
Time: 'time',
2022-03-23 11:46:13 +05:30
Text: 'text',
Data: 'text',
Link: 'text',
DynamicLink: 'text',
Password: 'text',
Select: 'text',
2022-03-25 15:42:39 +05:30
File: 'binary',
2022-03-23 11:46:13 +05:30
Attach: 'text',
AttachImage: 'text',
Color: 'text',
};
export const SYSTEM = '__SYSTEM__';
2022-03-23 11:46:13 +05:30
export const validTypes = Object.keys(sqliteTypeMap);
export function getDefaultMetaFieldValueMap() {
const now = new Date().toISOString();
return {
createdBy: SYSTEM,
modifiedBy: SYSTEM,
created: now,
modified: now,
};
}
2022-03-31 12:48:32 +05:30
export const databaseMethodSet: Set<DatabaseMethod> = new Set([
'insert',
'get',
'getAll',
'getSingleValues',
'rename',
'update',
'delete',
'close',
'exists',
]);