diff --git a/packages/node-sdk/paima-db/src/sql/achievements.queries.ts b/packages/node-sdk/paima-db/src/sql/achievements.queries.ts index 92f954ba..a174a400 100644 --- a/packages/node-sdk/paima-db/src/sql/achievements.queries.ts +++ b/packages/node-sdk/paima-db/src/sql/achievements.queries.ts @@ -1,6 +1,8 @@ /** Types generated for queries found in "src/sql/achievements.sql" */ import { PreparedQuery } from '@pgtyped/runtime'; +export type DateOrString = Date | string; + /** 'GetAchievementProgress' parameters type */ export interface IGetAchievementProgressParams { names: readonly (string | null | void)[]; @@ -35,3 +37,38 @@ const getAchievementProgressIR: any = {"usedParamSet":{"wallet":true,"names":tru export const getAchievementProgress = new PreparedQuery(getAchievementProgressIR); +/** 'SetAchievementProgress' parameters type */ +export interface ISetAchievementProgressParams { + completed_date?: DateOrString | null | void; + name: string; + progress?: number | null | void; + total?: number | null | void; + wallet: string; +} + +/** 'SetAchievementProgress' return type */ +export type ISetAchievementProgressResult = void; + +/** 'SetAchievementProgress' query type */ +export interface ISetAchievementProgressQuery { + params: ISetAchievementProgressParams; + result: ISetAchievementProgressResult; +} + +const setAchievementProgressIR: any = {"usedParamSet":{"wallet":true,"name":true,"completed_date":true,"progress":true,"total":true},"params":[{"name":"wallet","required":true,"transform":{"type":"scalar"},"locs":[{"a":89,"b":96}]},{"name":"name","required":true,"transform":{"type":"scalar"},"locs":[{"a":99,"b":104}]},{"name":"completed_date","required":false,"transform":{"type":"scalar"},"locs":[{"a":107,"b":121}]},{"name":"progress","required":false,"transform":{"type":"scalar"},"locs":[{"a":124,"b":132}]},{"name":"total","required":false,"transform":{"type":"scalar"},"locs":[{"a":135,"b":140}]}],"statement":"INSERT INTO achievement_progress (wallet, name, completed_date, progress, total)\nVALUES (:wallet!, :name!, :completed_date, :progress, :total)\nON CONFLICT (wallet, name)\nDO UPDATE SET\n completed_date = EXCLUDED.completed_date,\n progress = EXCLUDED.progress,\n total = EXCLUDED.total"}; + +/** + * Query generated from SQL: + * ``` + * INSERT INTO achievement_progress (wallet, name, completed_date, progress, total) + * VALUES (:wallet!, :name!, :completed_date, :progress, :total) + * ON CONFLICT (wallet, name) + * DO UPDATE SET + * completed_date = EXCLUDED.completed_date, + * progress = EXCLUDED.progress, + * total = EXCLUDED.total + * ``` + */ +export const setAchievementProgress = new PreparedQuery(setAchievementProgressIR); + + diff --git a/packages/node-sdk/paima-db/src/sql/achievements.sql b/packages/node-sdk/paima-db/src/sql/achievements.sql index fee2a190..cb4687c9 100644 --- a/packages/node-sdk/paima-db/src/sql/achievements.sql +++ b/packages/node-sdk/paima-db/src/sql/achievements.sql @@ -6,3 +6,12 @@ SELECT * FROM achievement_progress WHERE wallet = :wallet! AND ('*' in :names OR name IN :names) ; + +/* @name setAchievementProgress */ +INSERT INTO achievement_progress (wallet, name, completed_date, progress, total) +VALUES (:wallet!, :name!, :completed_date, :progress, :total) +ON CONFLICT (wallet, name) +DO UPDATE SET + completed_date = EXCLUDED.completed_date, + progress = EXCLUDED.progress, + total = EXCLUDED.total;