MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / writeGroupToCh

Function writeGroupToCh

packages/db/src/services/group.service.ts:52–79  ·  view source on GitHub ↗
(
  group: {
    id: string;
    projectId: string;
    type: string;
    name: string;
    properties: Record<string, string>;
    createdAt?: Date;
  },
  deleted = 0
)

Source from the content-addressed store, hash-verified

50}
51
52async 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
81export async function upsertGroup(input: IServiceUpsertGroup) {
82 const existing = await getGroupById(input.id, input.projectId);

Callers 3

upsertGroupFunction · 0.85
updateGroupFunction · 0.85
deleteGroupFunction · 0.85

Calls 1

formatClickhouseDateFunction · 0.90

Tested by

no test coverage detected