(
group: {
id: string;
projectId: string;
type: string;
name: string;
properties: Record<string, string>;
createdAt?: Date;
},
deleted = 0
)
| 50 | } |
| 51 | |
| 52 | async function writeGroupToCh( |
| 53 | group: { |
| 54 | id: string; |
| 55 | projectId: string; |
| 56 | type: string; |
| 57 | name: string; |
| 58 | properties: Record<string, string>; |
| 59 | createdAt?: Date; |
| 60 | }, |
| 61 | deleted = 0 |
| 62 | ) { |
| 63 | await ch.insert({ |
| 64 | format: 'JSONEachRow', |
| 65 | table: TABLE_NAMES.groups, |
| 66 | values: [ |
| 67 | { |
| 68 | project_id: group.projectId, |
| 69 | id: group.id, |
| 70 | type: group.type, |
| 71 | name: group.name, |
| 72 | properties: group.properties, |
| 73 | created_at: formatClickhouseDate(group.createdAt ?? new Date()), |
| 74 | version: Date.now(), |
| 75 | deleted, |
| 76 | }, |
| 77 | ], |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | export async function upsertGroup(input: IServiceUpsertGroup) { |
| 82 | const existing = await getGroupById(input.id, input.projectId); |
no test coverage detected