MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / upsertPlugin

Function upsertPlugin

app/src/sqlite/plugin.ts:8–28  ·  view source on GitHub ↗
(plugin: Plugin)

Source from the content-addressed store, hash-verified

6
7export const pluginCollectionMethods = {
8 async upsertPlugin(plugin: Plugin) {
9 const now = C.getDate().getTime()
10 await rd.exec(
11 `INSERT INTO plugin (name,version,dependencies,created,edited,script)
12 VALUES ( ?, ?, ?, ?, ?, ?)
13 ON CONFLICT(name) DO UPDATE SET
14 version=excluded.version,
15 dependencies=excluded.dependencies,
16 edited=excluded.edited,
17 script=excluded.script`,
18 // lowTODO add conflict types via typescript, i.e. "point of this type is to cause an error if something is added to Plugin"
19 [
20 plugin.name,
21 plugin.version,
22 plugin.dependencies ?? null,
23 now,
24 now,
25 new Uint8Array(await plugin.script.arrayBuffer()),
26 ],
27 )
28 },
29 async getPlugins(): Promise<Plugin[]> {
30 const plugins = await ky.selectFrom('plugin').selectAll().execute()
31 return plugins.map(pluginEntityToDomain)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected