From 94871d0e60372bf4a7c14ad89393045f1de466fe Mon Sep 17 00:00:00 2001 From: hobbescodes <87732294+hobbescodes@users.noreply.github.com> Date: Mon, 30 Dec 2024 22:27:41 -0600 Subject: [PATCH 1/7] feature(schema): add comments table --- src/generated/graphql/schema.executable.ts | 5667 +++++++++++++---- .../migrations/0002_high_ender_wiggin.sql | 11 + .../migrations/meta/0002_snapshot.json | 561 ++ src/lib/drizzle/migrations/meta/_journal.json | 7 + src/lib/drizzle/schema/comment.table.ts | 48 + src/lib/drizzle/schema/index.ts | 1 + src/lib/drizzle/schema/post.table.ts | 2 + src/scripts/seedDatabase.ts | 20 +- src/server.ts | 4 +- 9 files changed, 5174 insertions(+), 1147 deletions(-) create mode 100644 src/lib/drizzle/migrations/0002_high_ender_wiggin.sql create mode 100644 src/lib/drizzle/migrations/meta/0002_snapshot.json create mode 100644 src/lib/drizzle/schema/comment.table.ts diff --git a/src/generated/graphql/schema.executable.ts b/src/generated/graphql/schema.executable.ts index 49e4587..7dce1b6 100644 --- a/src/generated/graphql/schema.executable.ts +++ b/src/generated/graphql/schema.executable.ts @@ -120,7 +120,7 @@ const spec_userOrganization = { }), description: undefined, extensions: { - oid: "77600", + oid: "77872", isTableLike: true, pg: { serviceName: "main", @@ -200,7 +200,7 @@ const spec_upvote = { }), description: undefined, extensions: { - oid: "77578", + oid: "77850", isTableLike: true, pg: { serviceName: "main", @@ -280,7 +280,7 @@ const spec_organization = { }), description: undefined, extensions: { - oid: "77540", + oid: "77812", isTableLike: true, pg: { serviceName: "main", @@ -292,6 +292,98 @@ const spec_organization = { executor: executor }; const organizationCodec = recordCodec(spec_organization); +const commentIdentifier = sql.identifier("public", "comment"); +const spec_comment = { + name: "comment", + identifier: commentIdentifier, + attributes: Object.assign(Object.create(null), { + id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + message: { + description: undefined, + codec: TYPES.text, + notNull: false, + hasDefault: false, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + post_id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: false, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + user_id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: false, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + created_at: { + description: undefined, + codec: TYPES.timestamptz, + notNull: false, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + updated_at: { + description: undefined, + codec: TYPES.timestamptz, + notNull: false, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + } + }), + description: undefined, + extensions: { + oid: "78467", + isTableLike: true, + pg: { + serviceName: "main", + schemaName: "public", + name: "comment" + }, + tags: Object.create(null) + }, + executor: executor +}; +const commentCodec = recordCodec(spec_comment); const postIdentifier = sql.identifier("public", "post"); const spec_post = { name: "post", @@ -384,7 +476,7 @@ const spec_post = { }), description: undefined, extensions: { - oid: "77554", + oid: "77826", isTableLike: true, pg: { serviceName: "main", @@ -500,7 +592,7 @@ const spec_project = { }), description: undefined, extensions: { - oid: "77564", + oid: "77836", isTableLike: true, pg: { serviceName: "main", @@ -604,7 +696,7 @@ const spec_user = { }), description: undefined, extensions: { - oid: "77588", + oid: "77860", isTableLike: true, pg: { serviceName: "main", @@ -738,6 +830,40 @@ const registryConfig_pgResources_organization_organization = { canDelete: true } }; +const commentUniques = [{ + isPrimary: true, + attributes: ["id"], + description: undefined, + extensions: { + tags: Object.create(null) + } +}]; +const registryConfig_pgResources_comment_comment = { + executor: executor, + name: "comment", + identifier: "main.public.comment", + from: commentIdentifier, + codec: commentCodec, + uniques: commentUniques, + isVirtual: false, + description: undefined, + extensions: { + description: undefined, + pg: { + serviceName: "main", + schemaName: "public", + name: "comment" + }, + isInsertable: true, + isUpdatable: true, + isDeletable: true, + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true, + canDelete: true + } +}; const postUniques = [{ isPrimary: true, attributes: ["id"], @@ -879,6 +1005,7 @@ const registryConfig = { upvote: upvoteCodec, organization: organizationCodec, text: TYPES.text, + comment: commentCodec, post: postCodec, project: projectCodec, user: userCodec @@ -887,11 +1014,44 @@ const registryConfig = { user_organization: registryConfig_pgResources_user_organization_user_organization, upvote: registryConfig_pgResources_upvote_upvote, organization: registryConfig_pgResources_organization_organization, + comment: registryConfig_pgResources_comment_comment, post: registryConfig_pgResources_post_post, user: registryConfig_pgResources_user_user, project: registryConfig_pgResources_project_project }), pgRelations: Object.assign(Object.create(null), { + comment: Object.assign(Object.create(null), { + postByMyPostId: { + localCodec: commentCodec, + remoteResourceOptions: registryConfig_pgResources_post_post, + localCodecPolymorphicTypes: undefined, + localAttributes: ["post_id"], + remoteAttributes: ["id"], + isUnique: true, + isReferencee: false, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } + }, + userByMyUserId: { + localCodec: commentCodec, + remoteResourceOptions: registryConfig_pgResources_user_user, + localCodecPolymorphicTypes: undefined, + localAttributes: ["user_id"], + remoteAttributes: ["id"], + isUnique: true, + isReferencee: false, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } + } + }), organization: Object.assign(Object.create(null), { projectsByTheirOrganizationId: { localCodec: organizationCodec, @@ -969,6 +1129,21 @@ const registryConfig = { behavior: [] } } + }, + commentsByTheirPostId: { + localCodec: postCodec, + remoteResourceOptions: registryConfig_pgResources_comment_comment, + localCodecPolymorphicTypes: undefined, + localAttributes: ["id"], + remoteAttributes: ["post_id"], + isUnique: false, + isReferencee: true, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } } }), project: Object.assign(Object.create(null), { @@ -1080,6 +1255,21 @@ const registryConfig = { behavior: [] } } + }, + commentsByTheirUserId: { + localCodec: userCodec, + remoteResourceOptions: registryConfig_pgResources_comment_comment, + localCodecPolymorphicTypes: undefined, + localAttributes: ["id"], + remoteAttributes: ["user_id"], + isUnique: false, + isReferencee: true, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } } }), userOrganization: Object.assign(Object.create(null), { @@ -1119,6 +1309,7 @@ const registryConfig = { const registry = makeRegistry(registryConfig); const pgResource_upvotePgResource = registry.pgResources["upvote"]; const pgResource_organizationPgResource = registry.pgResources["organization"]; +const pgResource_commentPgResource = registry.pgResources["comment"]; const pgResource_postPgResource = registry.pgResources["post"]; const pgResource_userPgResource = registry.pgResources["user"]; const pgResource_projectPgResource = registry.pgResources["project"]; @@ -1162,6 +1353,25 @@ const nodeIdHandlerByTypeName = Object.assign(Object.create(null), { return obj[0] === "Organization"; } }, + Comment: { + typeName: "Comment", + codec: nodeIdCodecs_base64JSON_base64JSON, + deprecationReason: undefined, + plan($record) { + return list([constant("Comment", false), $record.get("id")]); + }, + getSpec($list) { + return { + id: inhibitOnNull(access($list, [1])) + }; + }, + get(spec) { + return pgResource_commentPgResource.get(spec); + }, + match(obj) { + return obj[0] === "Comment"; + } + }, Post: { typeName: "Post", codec: nodeIdCodecs_base64JSON_base64JSON, @@ -1256,7 +1466,7 @@ const fetcher3 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.Post); +})(nodeIdHandlerByTypeName.Comment); const fetcher4 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1264,7 +1474,7 @@ const fetcher4 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.User); +})(nodeIdHandlerByTypeName.Post); const fetcher5 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1272,6 +1482,14 @@ const fetcher5 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; +})(nodeIdHandlerByTypeName.User); +const fetcher6 = (handler => { + const fn = $nodeId => { + const $decoded = lambda($nodeId, specForHandler(handler)); + return handler.get(handler.getSpec($decoded)); + }; + fn.deprecationReason = handler.deprecationReason; + return fn; })(nodeIdHandlerByTypeName.Project); const applyOrderToPlan = ($select, $value, TableOrderByType) => { if (!("evalLength" in $value)) return; @@ -1360,6 +1578,18 @@ function assertAllowed6(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } +function assertAllowed7(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} function UUIDSerialize(value) { return "" + value; } @@ -1367,7 +1597,7 @@ const coerce = string => { if (!/^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i.test(string)) throw new GraphQLError("Invalid UUID, expected 32 hexadecimal characters, optionally with hypens"); return string; }; -function assertAllowed7(fieldArgs, mode) { +function assertAllowed8(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1379,7 +1609,7 @@ function assertAllowed7(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed8(fieldArgs, mode) { +function assertAllowed9(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1545,7 +1775,7 @@ export const ProjectGroupBy = new GraphQLEnumType({ } }) }); -function assertAllowed9(fieldArgs, mode) { +function assertAllowed10(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1693,7 +1923,7 @@ export const PostGroupBy = new GraphQLEnumType({ } }) }); -function assertAllowed10(fieldArgs, mode) { +function assertAllowed11(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1705,7 +1935,7 @@ function assertAllowed10(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed11(fieldArgs, mode) { +function assertAllowed12(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1717,7 +1947,7 @@ function assertAllowed11(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed12(fieldArgs, mode) { +function assertAllowed13(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1729,7 +1959,31 @@ function assertAllowed12(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed13(fieldArgs, mode) { +function assertAllowed14(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed15(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed16(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1759,6 +2013,7 @@ const aggregateSpec = { return (_b = oid ? dataTypeToAggregateTypeMap[oid] : null) !== null && _b !== void 0 ? _b : TYPES.bigint; } }; +const relation2 = registry.pgRelations["post"]["commentsByTheirPostId"]; const colSpec = { fieldName: "rowId", attributeName: "id", @@ -1794,7 +2049,7 @@ const colSpec7 = { attributeName: "updated_at", attribute: spec_post.attributes.updated_at }; -function assertAllowed14(fieldArgs, mode) { +function assertAllowed17(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1806,7 +2061,7 @@ function assertAllowed14(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed15(fieldArgs, mode) { +function assertAllowed18(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1818,7 +2073,7 @@ function assertAllowed15(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed16(fieldArgs, mode) { +function assertAllowed19(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2252,7 +2507,7 @@ const resolve46 = (i, v) => sql`${i} < ${v}`; const resolve47 = (i, v) => sql`${i} <= ${v}`; const resolve48 = (i, v) => sql`${i} > ${v}`; const resolve49 = (i, v) => sql`${i} >= ${v}`; -function assertAllowed17(fieldArgs, mode) { +function assertAllowed20(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2352,7 +2607,7 @@ const colSpec12 = { attributeName: "updated_at", attribute: spec_upvote.attributes.updated_at }; -function assertAllowed18(fieldArgs, mode) { +function assertAllowed21(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2364,7 +2619,7 @@ function assertAllowed18(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed19(fieldArgs, mode) { +function assertAllowed22(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2411,7 +2666,7 @@ const colSpec19 = { attributeName: "last_name", attribute: spec_user.attributes.last_name }; -function assertAllowed20(fieldArgs, mode) { +function assertAllowed23(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2423,7 +2678,7 @@ function assertAllowed20(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed21(fieldArgs, mode) { +function assertAllowed24(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2435,7 +2690,7 @@ function assertAllowed21(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed22(fieldArgs, mode) { +function assertAllowed25(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2497,7 +2752,7 @@ const resolve57 = (i, v) => sql`${i} < ${v}`; const resolve58 = (i, v) => sql`${i} <= ${v}`; const resolve59 = (i, v) => sql`${i} > ${v}`; const resolve60 = (i, v) => sql`${i} >= ${v}`; -function assertAllowed23(fieldArgs, mode) { +function assertAllowed26(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2509,7 +2764,7 @@ function assertAllowed23(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed24(fieldArgs, mode) { +function assertAllowed27(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2536,7 +2791,7 @@ const colSpec22 = { attributeName: "created_at", attribute: spec_userOrganization.attributes.created_at }; -function assertAllowed25(fieldArgs, mode) { +function assertAllowed28(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2548,7 +2803,7 @@ function assertAllowed25(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed26(fieldArgs, mode) { +function assertAllowed29(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2585,7 +2840,7 @@ const colSpec27 = { attributeName: "updated_at", attribute: spec_organization.attributes.updated_at }; -function assertAllowed27(fieldArgs, mode) { +function assertAllowed30(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2597,7 +2852,7 @@ function assertAllowed27(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed28(fieldArgs, mode) { +function assertAllowed31(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2609,7 +2864,7 @@ function assertAllowed28(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed29(fieldArgs, mode) { +function assertAllowed32(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2661,7 +2916,7 @@ const colSpec35 = { attributeName: "updated_at", attribute: spec_project.attributes.updated_at }; -function assertAllowed30(fieldArgs, mode) { +function assertAllowed33(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2673,7 +2928,7 @@ function assertAllowed30(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed31(fieldArgs, mode) { +function assertAllowed34(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2685,7 +2940,7 @@ function assertAllowed31(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed32(fieldArgs, mode) { +function assertAllowed35(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2697,7 +2952,7 @@ function assertAllowed32(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed33(fieldArgs, mode) { +function assertAllowed36(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2709,7 +2964,85 @@ function assertAllowed33(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed34(fieldArgs, mode) { +function assertAllowed37(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed38(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +const colSpec36 = { + fieldName: "rowId", + attributeName: "id", + attribute: spec_comment.attributes.id +}; +const colSpec37 = { + fieldName: "message", + attributeName: "message", + attribute: spec_comment.attributes.message +}; +const colSpec38 = { + fieldName: "postId", + attributeName: "post_id", + attribute: spec_comment.attributes.post_id +}; +const colSpec39 = { + fieldName: "userId", + attributeName: "user_id", + attribute: spec_comment.attributes.user_id +}; +const colSpec40 = { + fieldName: "createdAt", + attributeName: "created_at", + attribute: spec_comment.attributes.created_at +}; +const colSpec41 = { + fieldName: "updatedAt", + attributeName: "updated_at", + attribute: spec_comment.attributes.updated_at +}; +function assertAllowed39(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed40(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed41(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -3054,7 +3387,130 @@ export const UserOrganizationGroupBy = new GraphQLEnumType({ } }) }); -const relation2 = registry.pgRelations["project"]["postsByTheirProjectId"]; +function CommentGroupBy_extensions_grafast_applyPlan($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("message")}` + }); +} +function CommentGroupBy_extensions_grafast_applyPlan2($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("post_id")}` + }); +} +function CommentGroupBy_extensions_grafast_applyPlan3($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("user_id")}` + }); +} +function CommentGroupBy_extensions_grafast_applyPlan4($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` + }); +} +function CommentGroupBy_extensions_grafast_applyPlan5($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("created_at")}`) + }); +} +function CommentGroupBy_extensions_grafast_applyPlan6($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec2.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("created_at")}`) + }); +} +function CommentGroupBy_extensions_grafast_applyPlan7($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("updated_at")}` + }); +} +function CommentGroupBy_extensions_grafast_applyPlan8($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("updated_at")}`) + }); +} +function CommentGroupBy_extensions_grafast_applyPlan9($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec2.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("updated_at")}`) + }); +} +export const CommentGroupBy = new GraphQLEnumType({ + name: "CommentGroupBy", + description: "Grouping methods for `Comment` for usage during aggregation.", + values: Object.assign(Object.create(null), { + MESSAGE: { + value: "MESSAGE", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan + } + }) + }, + POST_ID: { + value: "POST_ID", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan2 + } + }) + }, + USER_ID: { + value: "USER_ID", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan3 + } + }) + }, + CREATED_AT: { + value: "CREATED_AT", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan4 + } + }) + }, + CREATED_AT_TRUNCATED_TO_HOUR: { + value: "CREATED_AT_TRUNCATED_TO_HOUR", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan5 + } + }) + }, + CREATED_AT_TRUNCATED_TO_DAY: { + value: "CREATED_AT_TRUNCATED_TO_DAY", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan6 + } + }) + }, + UPDATED_AT: { + value: "UPDATED_AT", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan7 + } + }) + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + value: "UPDATED_AT_TRUNCATED_TO_HOUR", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan8 + } + }) + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + value: "UPDATED_AT_TRUNCATED_TO_DAY", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan9 + } + }) + } + }) +}); +const relation3 = registry.pgRelations["project"]["postsByTheirProjectId"]; function OrganizationGroupBy_extensions_grafast_applyPlan($pgSelect) { $pgSelect.groupBy({ fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` @@ -3139,8 +3595,8 @@ export const OrganizationGroupBy = new GraphQLEnumType({ } }) }); -const relation3 = registry.pgRelations["organization"]["projectsByTheirOrganizationId"]; -const relation4 = registry.pgRelations["organization"]["userOrganizationsByTheirOrganizationId"]; +const relation4 = registry.pgRelations["organization"]["projectsByTheirOrganizationId"]; +const relation5 = registry.pgRelations["organization"]["userOrganizationsByTheirOrganizationId"]; function UserGroupBy_extensions_grafast_applyPlan($pgSelect) { $pgSelect.groupBy({ fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` @@ -3251,9 +3707,10 @@ export const UserGroupBy = new GraphQLEnumType({ } }) }); -const relation5 = registry.pgRelations["user"]["postsByTheirUserId"]; -const relation6 = registry.pgRelations["user"]["upvotesByTheirUserId"]; -const relation7 = registry.pgRelations["user"]["userOrganizationsByTheirUserId"]; +const relation6 = registry.pgRelations["user"]["postsByTheirUserId"]; +const relation7 = registry.pgRelations["user"]["upvotesByTheirUserId"]; +const relation8 = registry.pgRelations["user"]["userOrganizationsByTheirUserId"]; +const relation9 = registry.pgRelations["user"]["commentsByTheirUserId"]; const specFromArgs = args => { const $nodeId = args.get(["input", "id"]); return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); @@ -3264,33 +3721,41 @@ const specFromArgs2 = args => { }; const specFromArgs3 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); }; const specFromArgs4 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); }; const specFromArgs5 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); }; const specFromArgs6 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); }; const specFromArgs7 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); }; const specFromArgs8 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); }; const specFromArgs9 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); }; const specFromArgs10 = args => { + const $nodeId = args.get(["input", "id"]); + return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); +}; +const specFromArgs11 = args => { + const $nodeId = args.get(["input", "id"]); + return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); +}; +const specFromArgs12 = args => { const $nodeId = args.get(["input", "id"]); return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); }; @@ -3331,6 +3796,9 @@ type Query implements Node { """Get a single \`Organization\`.""" organizationBySlug(slug: String!): Organization + """Get a single \`Comment\`.""" + comment(rowId: UUID!): Comment + """Get a single \`Post\`.""" post(rowId: UUID!): Post @@ -3366,6 +3834,12 @@ type Query implements Node { id: ID! ): Organization + """Reads a single \`Comment\` using its globally unique \`ID\`.""" + commentById( + """The globally unique \`ID\` to be used in selecting a single \`Comment\`.""" + id: ID! + ): Comment + """Reads a single \`Post\` using its globally unique \`ID\`.""" postById( """The globally unique \`ID\` to be used in selecting a single \`Post\`.""" @@ -3486,6 +3960,40 @@ type Query implements Node { filter: OrganizationFilter ): OrganizationConnection + """Reads and enables pagination through a set of \`Comment\`.""" + comments( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: CommentCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: CommentFilter + ): CommentConnection + """Reads and enables pagination through a set of \`Post\`.""" posts( """Only read the first \`n\` values of the set.""" @@ -3875,6 +4383,40 @@ type Post implements Node { """ filter: UpvoteFilter ): UpvoteConnection! + + """Reads and enables pagination through a set of \`Comment\`.""" + comments( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: CommentCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: CommentFilter + ): CommentConnection! } type User implements Node { @@ -3991,6 +4533,40 @@ type User implements Node { """ filter: UserOrganizationFilter ): UserOrganizationConnection! + + """Reads and enables pagination through a set of \`Comment\`.""" + comments( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: CommentCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: CommentFilter + ): CommentConnection! } """A location in a connection that can be used for resuming pagination.""" @@ -4027,6 +4603,20 @@ enum PostOrderBy { UPVOTES_DISTINCT_COUNT_CREATED_AT_DESC UPVOTES_DISTINCT_COUNT_UPDATED_AT_ASC UPVOTES_DISTINCT_COUNT_UPDATED_AT_DESC + COMMENTS_COUNT_ASC + COMMENTS_COUNT_DESC + COMMENTS_DISTINCT_COUNT_ROW_ID_ASC + COMMENTS_DISTINCT_COUNT_ROW_ID_DESC + COMMENTS_DISTINCT_COUNT_MESSAGE_ASC + COMMENTS_DISTINCT_COUNT_MESSAGE_DESC + COMMENTS_DISTINCT_COUNT_POST_ID_ASC + COMMENTS_DISTINCT_COUNT_POST_ID_DESC + COMMENTS_DISTINCT_COUNT_USER_ID_ASC + COMMENTS_DISTINCT_COUNT_USER_ID_DESC + COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC + COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC + COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC + COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC } """ @@ -4086,6 +4676,12 @@ input PostFilter { """Some related \`upvotes\` exist.""" upvotesExist: Boolean + """Filter by the object’s \`comments\` relation.""" + comments: PostToManyCommentFilter + + """Some related \`comments\` exist.""" + commentsExist: Boolean + """Filter by the object’s \`project\` relation.""" project: ProjectFilter @@ -4419,6 +5015,12 @@ input UserFilter { """Some related \`userOrganizations\` exist.""" userOrganizationsExist: Boolean + """Filter by the object’s \`comments\` relation.""" + comments: UserToManyCommentFilter + + """Some related \`comments\` exist.""" + commentsExist: Boolean + """Checks for all expressions in this list.""" and: [UserFilter!] @@ -4818,6 +5420,110 @@ input UserOrganizationDistinctCountAggregateFilter { createdAt: BigIntFilter } +""" +A filter to be used against many \`Comment\` object types. All fields are combined with a logical ‘and.’ +""" +input UserToManyCommentFilter { + """ + Every related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + every: CommentFilter + + """ + Some related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + some: CommentFilter + + """ + No related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + none: CommentFilter + + """Aggregates across related \`Comment\` match the filter criteria.""" + aggregates: CommentAggregatesFilter +} + +""" +A filter to be used against \`Comment\` object types. All fields are combined with a logical ‘and.’ +""" +input CommentFilter { + """Filter by the object’s \`rowId\` field.""" + rowId: UUIDFilter + + """Filter by the object’s \`message\` field.""" + message: StringFilter + + """Filter by the object’s \`postId\` field.""" + postId: UUIDFilter + + """Filter by the object’s \`userId\` field.""" + userId: UUIDFilter + + """Filter by the object’s \`createdAt\` field.""" + createdAt: DatetimeFilter + + """Filter by the object’s \`updatedAt\` field.""" + updatedAt: DatetimeFilter + + """Filter by the object’s \`post\` relation.""" + post: PostFilter + + """Filter by the object’s \`user\` relation.""" + user: UserFilter + + """Checks for all expressions in this list.""" + and: [CommentFilter!] + + """Checks for any expressions in this list.""" + or: [CommentFilter!] + + """Negates the expression.""" + not: CommentFilter +} + +"""A filter to be used against aggregates of \`Comment\` object types.""" +input CommentAggregatesFilter { + """ + A filter that must pass for the relevant \`Comment\` object to be included within the aggregate. + """ + filter: CommentFilter + + """Distinct count aggregate over matching \`Comment\` objects.""" + distinctCount: CommentDistinctCountAggregateFilter +} + +input CommentDistinctCountAggregateFilter { + rowId: BigIntFilter + message: BigIntFilter + postId: BigIntFilter + userId: BigIntFilter + createdAt: BigIntFilter + updatedAt: BigIntFilter +} + +""" +A filter to be used against many \`Comment\` object types. All fields are combined with a logical ‘and.’ +""" +input PostToManyCommentFilter { + """ + Every related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + every: CommentFilter + + """ + Some related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + some: CommentFilter + + """ + No related \`Comment\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + none: CommentFilter + + """Aggregates across related \`Comment\` match the filter criteria.""" + aggregates: CommentAggregatesFilter +} + """A connection to a list of \`Upvote\` values.""" type UpvoteConnection { """A list of \`Upvote\` objects.""" @@ -5189,6 +5895,211 @@ input UserOrganizationCondition { createdAt: Datetime } +"""A connection to a list of \`Comment\` values.""" +type CommentConnection { + """A list of \`Comment\` objects.""" + nodes: [Comment]! + + """ + A list of edges which contains the \`Comment\` and cursor to aid in pagination. + """ + edges: [CommentEdge]! + + """Information to aid in pagination.""" + pageInfo: PageInfo! + + """The count of *all* \`Comment\` you could get from the connection.""" + totalCount: Int! + + """ + Aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + aggregates: CommentAggregates + + """ + Grouped aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + groupedAggregates( + """The method to use when grouping \`Comment\` for these aggregates.""" + groupBy: [CommentGroupBy!]! + + """Conditions on the grouped aggregates.""" + having: CommentHavingInput + ): [CommentAggregates!] +} + +type Comment implements Node { + """ + A globally unique identifier. Can be used in various places throughout the system to identify this single value. + """ + id: ID! + rowId: UUID! + message: String + postId: UUID! + userId: UUID! + createdAt: Datetime + updatedAt: Datetime + + """Reads a single \`Post\` that is related to this \`Comment\`.""" + post: Post + + """Reads a single \`User\` that is related to this \`Comment\`.""" + user: User +} + +"""A \`Comment\` edge in the connection.""" +type CommentEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The \`Comment\` at the end of the edge.""" + node: Comment +} + +type CommentAggregates { + keys: [String] + + """ + Distinct count aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + distinctCount: CommentDistinctCountAggregates +} + +type CommentDistinctCountAggregates { + """Distinct count of rowId across the matching connection""" + rowId: BigInt + + """Distinct count of message across the matching connection""" + message: BigInt + + """Distinct count of postId across the matching connection""" + postId: BigInt + + """Distinct count of userId across the matching connection""" + userId: BigInt + + """Distinct count of createdAt across the matching connection""" + createdAt: BigInt + + """Distinct count of updatedAt across the matching connection""" + updatedAt: BigInt +} + +"""Grouping methods for \`Comment\` for usage during aggregation.""" +enum CommentGroupBy { + MESSAGE + POST_ID + USER_ID + CREATED_AT + CREATED_AT_TRUNCATED_TO_HOUR + CREATED_AT_TRUNCATED_TO_DAY + UPDATED_AT + UPDATED_AT_TRUNCATED_TO_HOUR + UPDATED_AT_TRUNCATED_TO_DAY +} + +"""Conditions for \`Comment\` aggregates.""" +input CommentHavingInput { + AND: [CommentHavingInput!] + OR: [CommentHavingInput!] + sum: CommentHavingSumInput + distinctCount: CommentHavingDistinctCountInput + min: CommentHavingMinInput + max: CommentHavingMaxInput + average: CommentHavingAverageInput + stddevSample: CommentHavingStddevSampleInput + stddevPopulation: CommentHavingStddevPopulationInput + varianceSample: CommentHavingVarianceSampleInput + variancePopulation: CommentHavingVariancePopulationInput +} + +input CommentHavingSumInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingDistinctCountInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingMinInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingMaxInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingAverageInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingStddevSampleInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingStddevPopulationInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingVarianceSampleInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input CommentHavingVariancePopulationInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +"""Methods to use when ordering \`Comment\`.""" +enum CommentOrderBy { + NATURAL + PRIMARY_KEY_ASC + PRIMARY_KEY_DESC + ROW_ID_ASC + ROW_ID_DESC + MESSAGE_ASC + MESSAGE_DESC + POST_ID_ASC + POST_ID_DESC + USER_ID_ASC + USER_ID_DESC + CREATED_AT_ASC + CREATED_AT_DESC + UPDATED_AT_ASC + UPDATED_AT_DESC +} + +""" +A condition to be used against \`Comment\` object types. All fields are tested for equality and combined with a logical ‘and.’ +""" +input CommentCondition { + """Checks for equality with the object’s \`rowId\` field.""" + rowId: UUID + + """Checks for equality with the object’s \`message\` field.""" + message: String + + """Checks for equality with the object’s \`postId\` field.""" + postId: UUID + + """Checks for equality with the object’s \`userId\` field.""" + userId: UUID + + """Checks for equality with the object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the object’s \`updatedAt\` field.""" + updatedAt: Datetime +} + """A \`Post\` edge in the connection.""" type PostEdge { """A cursor for use in pagination.""" @@ -5893,6 +6804,20 @@ enum UserOrderBy { USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_DESC USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_ASC USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_DESC + COMMENTS_COUNT_ASC + COMMENTS_COUNT_DESC + COMMENTS_DISTINCT_COUNT_ROW_ID_ASC + COMMENTS_DISTINCT_COUNT_ROW_ID_DESC + COMMENTS_DISTINCT_COUNT_MESSAGE_ASC + COMMENTS_DISTINCT_COUNT_MESSAGE_DESC + COMMENTS_DISTINCT_COUNT_POST_ID_ASC + COMMENTS_DISTINCT_COUNT_POST_ID_DESC + COMMENTS_DISTINCT_COUNT_USER_ID_ASC + COMMENTS_DISTINCT_COUNT_USER_ID_DESC + COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC + COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC + COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC + COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC } """ @@ -5949,6 +6874,14 @@ type Mutation { input: CreateOrganizationInput! ): CreateOrganizationPayload + """Creates a single \`Comment\`.""" + createComment( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: CreateCommentInput! + ): CreateCommentPayload + """Creates a single \`Post\`.""" createPost( """ @@ -6039,15 +6972,31 @@ type Mutation { input: UpdateOrganizationBySlugInput! ): UpdateOrganizationPayload - """Updates a single \`Post\` using its globally unique id and a patch.""" - updatePostById( + """Updates a single \`Comment\` using its globally unique id and a patch.""" + updateCommentById( """ The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. """ - input: UpdatePostByIdInput! - ): UpdatePostPayload + input: UpdateCommentByIdInput! + ): UpdateCommentPayload - """Updates a single \`Post\` using a unique key and a patch.""" + """Updates a single \`Comment\` using a unique key and a patch.""" + updateComment( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: UpdateCommentInput! + ): UpdateCommentPayload + + """Updates a single \`Post\` using its globally unique id and a patch.""" + updatePostById( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: UpdatePostByIdInput! + ): UpdatePostPayload + + """Updates a single \`Post\` using a unique key and a patch.""" updatePost( """ The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. @@ -6183,6 +7132,22 @@ type Mutation { input: DeleteOrganizationBySlugInput! ): DeleteOrganizationPayload + """Deletes a single \`Comment\` using its globally unique id.""" + deleteCommentById( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: DeleteCommentByIdInput! + ): DeleteCommentPayload + + """Deletes a single \`Comment\` using a unique key.""" + deleteComment( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: DeleteCommentInput! + ): DeleteCommentPayload + """Deletes a single \`Post\` using its globally unique id.""" deletePostById( """ @@ -6388,6 +7353,51 @@ input OrganizationInput { updatedAt: Datetime } +"""The output of our create \`Comment\` mutation.""" +type CreateCommentPayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Comment\` that was created by this mutation.""" + comment: Comment + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Comment\`. May be used by Relay 1.""" + commentEdge( + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!]! = [PRIMARY_KEY_ASC] + ): CommentEdge +} + +"""All input for the create \`Comment\` mutation.""" +input CreateCommentInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """The \`Comment\` to be created by this mutation.""" + comment: CommentInput! +} + +"""An input for mutations affecting \`Comment\`""" +input CommentInput { + rowId: UUID + message: String + postId: UUID! + userId: UUID! + createdAt: Datetime + updatedAt: Datetime +} + """The output of our create \`Post\` mutation.""" type CreatePostPayload { """ @@ -6753,6 +7763,75 @@ input UpdateOrganizationBySlugInput { patch: OrganizationPatch! } +"""The output of our update \`Comment\` mutation.""" +type UpdateCommentPayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Comment\` that was updated by this mutation.""" + comment: Comment + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Comment\`. May be used by Relay 1.""" + commentEdge( + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!]! = [PRIMARY_KEY_ASC] + ): CommentEdge +} + +"""All input for the \`updateCommentById\` mutation.""" +input UpdateCommentByIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """ + The globally unique \`ID\` which will identify a single \`Comment\` to be updated. + """ + id: ID! + + """ + An object where the defined keys will be set on the \`Comment\` being updated. + """ + patch: CommentPatch! +} + +""" +Represents an update to a \`Comment\`. Fields that are set will be updated. +""" +input CommentPatch { + rowId: UUID + message: String + postId: UUID + userId: UUID + createdAt: Datetime + updatedAt: Datetime +} + +"""All input for the \`updateComment\` mutation.""" +input UpdateCommentInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + rowId: UUID! + + """ + An object where the defined keys will be set on the \`Comment\` being updated. + """ + patch: CommentPatch! +} + """The output of our update \`Post\` mutation.""" type UpdatePostPayload { """ @@ -7178,6 +8257,54 @@ input DeleteOrganizationBySlugInput { slug: String! } +"""The output of our delete \`Comment\` mutation.""" +type DeleteCommentPayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Comment\` that was deleted by this mutation.""" + comment: Comment + deletedCommentId: ID + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Comment\`. May be used by Relay 1.""" + commentEdge( + """The method to use when ordering \`Comment\`.""" + orderBy: [CommentOrderBy!]! = [PRIMARY_KEY_ASC] + ): CommentEdge +} + +"""All input for the \`deleteCommentById\` mutation.""" +input DeleteCommentByIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """ + The globally unique \`ID\` which will identify a single \`Comment\` to be deleted. + """ + id: ID! +} + +"""All input for the \`deleteComment\` mutation.""" +input DeleteCommentInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + rowId: UUID! +} + """The output of our delete \`Post\` mutation.""" type DeletePostPayload { """ @@ -7446,6 +8573,16 @@ export const plans = { slug: undefined } }, + comment: { + plan(_$root, args) { + return pgResource_commentPgResource.get({ + id: args.get("rowId") + }); + }, + args: { + rowId: undefined + } + }, post: { plan(_$root, args) { return pgResource_postPgResource.get({ @@ -7536,7 +8673,7 @@ export const plans = { id: undefined } }, - postById: { + commentById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher3($nodeId); @@ -7545,7 +8682,7 @@ export const plans = { id: undefined } }, - userById: { + postById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher4($nodeId); @@ -7554,7 +8691,7 @@ export const plans = { id: undefined } }, - projectById: { + userById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher5($nodeId); @@ -7563,6 +8700,15 @@ export const plans = { id: undefined } }, + projectById: { + plan(_$parent, args) { + const $nodeId = args.get("id"); + return fetcher6($nodeId); + }, + args: { + id: undefined + } + }, userOrganizations: { plan() { return connection(resource_user_organizationPgResource.find()); @@ -7752,6 +8898,69 @@ export const plans = { } } }, + comments: { + plan() { + return connection(pgResource_commentPgResource.find()); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed4(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + }, posts: { plan() { return connection(pgResource_postPgResource.find()); @@ -7805,7 +9014,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed4(fieldArgs, "object"); + assertAllowed5(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -7868,7 +9077,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed5(fieldArgs, "object"); + assertAllowed6(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -7931,7 +9140,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed6(fieldArgs, "object"); + assertAllowed7(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8059,7 +9268,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed7(fieldArgs, "object"); + assertAllowed8(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8125,7 +9334,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed8(fieldArgs, "object"); + assertAllowed9(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8272,7 +9481,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed9(fieldArgs, "object"); + assertAllowed10(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8421,7 +9630,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed10(fieldArgs, "object"); + assertAllowed11(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8430,38 +9639,104 @@ export const plans = { } } } - } - }, - User: { - __assertStep: assertPgClassSingleStep, - id($parent) { - const specifier = nodeIdHandlerByTypeName.User.plan($parent); - return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.User.codec.name].encode); - }, - rowId($record) { - return $record.get("id"); - }, - createdAt($record) { - return $record.get("created_at"); - }, - updatedAt($record) { - return $record.get("updated_at"); - }, - hidraId($record) { - return $record.get("hidra_id"); - }, - username($record) { - return $record.get("username"); }, - firstName($record) { - return $record.get("first_name"); - }, - lastName($record) { - return $record.get("last_name"); - }, - posts: { + comments: { plan($record) { - const $records = pgResource_postPgResource.find({ + const $records = pgResource_commentPgResource.find({ + post_id: $record.get("id") + }); + return connection($records); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed12(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + } + }, + User: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.User.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.User.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); + }, + createdAt($record) { + return $record.get("created_at"); + }, + updatedAt($record) { + return $record.get("updated_at"); + }, + hidraId($record) { + return $record.get("hidra_id"); + }, + username($record) { + return $record.get("username"); + }, + firstName($record) { + return $record.get("first_name"); + }, + lastName($record) { + return $record.get("last_name"); + }, + posts: { + plan($record) { + const $records = pgResource_postPgResource.find({ user_id: $record.get("id") }); return connection($records); @@ -8515,7 +9790,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed11(fieldArgs, "object"); + assertAllowed13(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8581,7 +9856,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed12(fieldArgs, "object"); + assertAllowed14(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8647,7 +9922,73 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed13(fieldArgs, "object"); + assertAllowed15(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + }, + comments: { + plan($record) { + const $records = pgResource_commentPgResource.find({ + user_id: $record.get("id") + }); + return connection($records); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed16(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9143,65 +10484,369 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; direction: "DESC" }); } - } - }, - PostCondition: { - rowId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.id.codec)}`; - } + }, + COMMENTS_COUNT_ASC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "ASC" + }); + } }, - title: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "title", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "title", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.title.codec)}`; - } + COMMENTS_COUNT_DESC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "DESC" + }); + } }, - description: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "description", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "description", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.description.codec)}`; - } + COMMENTS_DISTINCT_COUNT_ROW_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_ROW_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, + direction: "DESC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_MESSAGE_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_MESSAGE_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, + direction: "DESC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_POST_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_POST_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, + direction: "DESC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_USER_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_USER_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, + direction: "DESC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, + direction: "DESC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, + direction: "ASC" + }); + } + }, + COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation2.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation2.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, + direction: "DESC" + }); + } + } + }, + PostCondition: { + rowId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + title: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "title", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "title", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.title.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + description: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "description", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "description", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.description.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true }, projectId: { applyPlan($condition, val) { @@ -9360,7 +11005,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotes: { applyPlan($where, fieldArgs) { - assertAllowed14(fieldArgs, "object"); + assertAllowed17(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: upvoteIdentifier, @@ -9373,7 +11018,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotesExist: { applyPlan($where, fieldArgs) { - assertAllowed14(fieldArgs, "scalar"); + assertAllowed17(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: upvoteIdentifier, alias: pgResource_upvotePgResource.name, @@ -9385,9 +11030,36 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); } }, + comments: { + applyPlan($where, fieldArgs) { + assertAllowed17(fieldArgs, "object"); + const $rel = $where.andPlan(); + $rel.extensions.pgFilterRelation = { + tableExpression: commentIdentifier, + alias: pgResource_commentPgResource.name, + localAttributes: registryConfig.pgRelations.post.commentsByTheirPostId.localAttributes, + remoteAttributes: registryConfig.pgRelations.post.commentsByTheirPostId.remoteAttributes + }; + fieldArgs.apply($rel); + } + }, + commentsExist: { + applyPlan($where, fieldArgs) { + assertAllowed17(fieldArgs, "scalar"); + const $subQuery = $where.existsPlan({ + tableExpression: commentIdentifier, + alias: pgResource_commentPgResource.name, + $equals: fieldArgs.get() + }); + registryConfig.pgRelations.post.commentsByTheirPostId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.post.commentsByTheirPostId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + } + }, project: { applyPlan($where, fieldArgs) { - assertAllowed15(fieldArgs, "object"); + assertAllowed18(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: projectIdentifier, alias: pgResource_projectPgResource.name @@ -9401,7 +11073,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed15(fieldArgs, "object"); + assertAllowed18(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -9415,21 +11087,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed16(fieldArgs, "list"); + assertAllowed19(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed16(fieldArgs, "list"); + assertAllowed19(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed16(fieldArgs, "object"); + assertAllowed19(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -11037,7 +12709,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; PostToManyUpvoteFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "object"); + assertAllowed20(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11058,7 +12730,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "object"); + assertAllowed20(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11079,7 +12751,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "object"); + assertAllowed20(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11178,7 +12850,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, post: { applyPlan($where, fieldArgs) { - assertAllowed18(fieldArgs, "object"); + assertAllowed21(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name @@ -11192,7 +12864,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed18(fieldArgs, "object"); + assertAllowed21(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -11206,21 +12878,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "list"); + assertAllowed22(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "list"); + assertAllowed22(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "object"); + assertAllowed22(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -11306,7 +12978,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, posts: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: postIdentifier, @@ -11319,7 +12991,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, postsExist: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "scalar"); + assertAllowed23(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name, @@ -11333,7 +13005,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotes: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: upvoteIdentifier, @@ -11346,7 +13018,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotesExist: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "scalar"); + assertAllowed23(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: upvoteIdentifier, alias: pgResource_upvotePgResource.name, @@ -11360,7 +13032,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizations: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: userOrganizationIdentifier, @@ -11373,7 +13045,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizationsExist: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "scalar"); + assertAllowed23(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: userOrganizationIdentifier, alias: resource_user_organizationPgResource.name, @@ -11385,23 +13057,50 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); } }, + comments: { + applyPlan($where, fieldArgs) { + assertAllowed23(fieldArgs, "object"); + const $rel = $where.andPlan(); + $rel.extensions.pgFilterRelation = { + tableExpression: commentIdentifier, + alias: pgResource_commentPgResource.name, + localAttributes: registryConfig.pgRelations.user.commentsByTheirUserId.localAttributes, + remoteAttributes: registryConfig.pgRelations.user.commentsByTheirUserId.remoteAttributes + }; + fieldArgs.apply($rel); + } + }, + commentsExist: { + applyPlan($where, fieldArgs) { + assertAllowed23(fieldArgs, "scalar"); + const $subQuery = $where.existsPlan({ + tableExpression: commentIdentifier, + alias: pgResource_commentPgResource.name, + $equals: fieldArgs.get() + }); + registryConfig.pgRelations.user.commentsByTheirUserId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.user.commentsByTheirUserId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + } + }, and: { applyPlan($where, fieldArgs) { - assertAllowed21(fieldArgs, "list"); + assertAllowed24(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed21(fieldArgs, "list"); + assertAllowed24(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed21(fieldArgs, "object"); + assertAllowed24(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -11410,7 +13109,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyPostFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "object"); + assertAllowed25(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11431,7 +13130,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "object"); + assertAllowed25(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11452,7 +13151,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "object"); + assertAllowed25(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11888,7 +13587,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyUpvoteFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11909,7 +13608,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -11930,7 +13629,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12039,7 +13738,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyUserOrganizationFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "object"); + assertAllowed27(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12060,7 +13759,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "object"); + assertAllowed27(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12081,7 +13780,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "object"); + assertAllowed27(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12158,7 +13857,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, organization: { applyPlan($where, fieldArgs) { - assertAllowed25(fieldArgs, "object"); + assertAllowed28(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: organizationIdentifier, alias: pgResource_organizationPgResource.name @@ -12172,7 +13871,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed25(fieldArgs, "object"); + assertAllowed28(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -12186,21 +13885,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "list"); + assertAllowed29(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "list"); + assertAllowed29(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "object"); + assertAllowed29(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -12264,7 +13963,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, projects: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "object"); + assertAllowed30(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: projectIdentifier, @@ -12277,7 +13976,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, projectsExist: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "scalar"); + assertAllowed30(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: projectIdentifier, alias: pgResource_projectPgResource.name, @@ -12291,7 +13990,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizations: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "object"); + assertAllowed30(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: userOrganizationIdentifier, @@ -12304,7 +14003,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizationsExist: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "scalar"); + assertAllowed30(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: userOrganizationIdentifier, alias: resource_user_organizationPgResource.name, @@ -12318,21 +14017,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed28(fieldArgs, "list"); + assertAllowed31(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed28(fieldArgs, "list"); + assertAllowed31(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed28(fieldArgs, "object"); + assertAllowed31(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -12341,7 +14040,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; OrganizationToManyProjectFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "object"); + assertAllowed32(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12362,7 +14061,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "object"); + assertAllowed32(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12383,7 +14082,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "object"); + assertAllowed32(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12515,7 +14214,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, posts: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "object"); + assertAllowed33(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: postIdentifier, @@ -12528,7 +14227,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, postsExist: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "scalar"); + assertAllowed33(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name, @@ -12542,7 +14241,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, organization: { applyPlan($where, fieldArgs) { - assertAllowed31(fieldArgs, "object"); + assertAllowed34(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: organizationIdentifier, alias: pgResource_organizationPgResource.name @@ -12556,21 +14255,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "list"); + assertAllowed35(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "list"); + assertAllowed35(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "object"); + assertAllowed35(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -12579,7 +14278,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; ProjectToManyPostFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed33(fieldArgs, "object"); + assertAllowed36(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12600,7 +14299,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed33(fieldArgs, "object"); + assertAllowed36(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12621,7 +14320,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed33(fieldArgs, "object"); + assertAllowed36(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12760,7 +14459,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; OrganizationToManyUserOrganizationFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed34(fieldArgs, "object"); + assertAllowed37(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12781,7 +14480,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed34(fieldArgs, "object"); + assertAllowed37(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12802,7 +14501,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed34(fieldArgs, "object"); + assertAllowed37(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12888,84 +14587,1086 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UpvoteConnection: { - __assertStep: ConnectionStep, - nodes($connection) { - return $connection.nodes(); - }, - edges($connection) { - return $connection.edges(); - }, - pageInfo($connection) { - return $connection.pageInfo(); + UserToManyCommentFilter: { + every: { + applyPlan($where, fieldArgs) { + assertAllowed38(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery.notPlan().andPlan()); + } }, - totalCount($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + some: { + applyPlan($where, fieldArgs) { + assertAllowed38(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } }, - aggregates($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate").single(); + none: { + applyPlan($where, fieldArgs) { + assertAllowed38(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } }, - groupedAggregates: { - plan($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate"); - }, - args: { - groupBy: { - autoApplyAfterParentPlan: true, - applyPlan(_$parent, $pgSelect, input) { - var _a, _b; - const val = input.getRaw().eval(); - if (!Array.isArray(val)) throw new Error("Invalid!"); - for (const group of val) { - const config = getEnumValueConfig(UpvoteGroupBy, group), - plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; - if (typeof plan === "function") plan($pgSelect); - } - return null; - } - }, - having: { - autoApplyAfterParentPlan: true, - applyPlan(_$parent, $pgSelect) { - return $pgSelect.havingPlan(); - } - } + aggregates: { + applyPlan($where, fieldArgs) { + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = new PgAggregateConditionStep($where, { + sql, + tableExpression, + alias + }, pgWhereConditionSpecListToSQL); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); } } }, - Upvote: { - __assertStep: assertPgClassSingleStep, - id($parent) { - const specifier = nodeIdHandlerByTypeName.Upvote.plan($parent); - return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Upvote.codec.name].encode); - }, - rowId($record) { - return $record.get("id"); - }, - postId($record) { - return $record.get("post_id"); + CommentFilter: { + rowId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec36; + fieldArgs.apply($col); + } }, - userId($record) { - return $record.get("user_id"); + message: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec37; + fieldArgs.apply($col); + } }, - createdAt($record) { - return $record.get("created_at"); + postId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec38; + fieldArgs.apply($col); + } }, - updatedAt($record) { - return $record.get("updated_at"); + userId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec39; + fieldArgs.apply($col); + } + }, + createdAt: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec40; + fieldArgs.apply($col); + } + }, + updatedAt: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec41; + fieldArgs.apply($col); + } + }, + post: { + applyPlan($where, fieldArgs) { + assertAllowed39(fieldArgs, "object"); + const $subQuery = $where.existsPlan({ + tableExpression: postIdentifier, + alias: pgResource_postPgResource.name + }); + registryConfig.pgRelations.comment.postByMyPostId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.comment.postByMyPostId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + user: { + applyPlan($where, fieldArgs) { + assertAllowed39(fieldArgs, "object"); + const $subQuery = $where.existsPlan({ + tableExpression: userIdentifier, + alias: pgResource_userPgResource.name + }); + registryConfig.pgRelations.comment.userByMyUserId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.comment.userByMyUserId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + and: { + applyPlan($where, fieldArgs) { + assertAllowed40(fieldArgs, "list"); + const $and = $where.andPlan(); + fieldArgs.apply($and); + } + }, + or: { + applyPlan($where, fieldArgs) { + assertAllowed40(fieldArgs, "list"); + const $or = $where.orPlan(); + fieldArgs.apply(() => $or.andPlan()); + } + }, + not: { + applyPlan($where, fieldArgs) { + assertAllowed40(fieldArgs, "object"); + const $and = $where.notPlan().andPlan(); + fieldArgs.apply($and); + } + } + }, + CommentAggregatesFilter: { + filter: { + applyPlan($subquery, fieldArgs) { + const $condition = new PgConditionStep($subquery, !1, "AND"); + fieldArgs.apply($condition); + } + }, + distinctCount: { + applyPlan($subquery, fieldArgs) { + fieldArgs.apply($subquery.forAggregate(aggregateSpec)); + } + } + }, + CommentDistinctCountAggregateFilter: { + rowId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec) + }; + fieldArgs.apply($col); + } + }, + message: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec) + }; + fieldArgs.apply($col); + } + }, + postId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec) + }; + fieldArgs.apply($col); + } + }, + userId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec) + }; + fieldArgs.apply($col); + } + }, + createdAt: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec) + }; + fieldArgs.apply($col); + } + }, + updatedAt: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec) + }; + fieldArgs.apply($col); + } + } + }, + PostToManyCommentFilter: { + every: { + applyPlan($where, fieldArgs) { + assertAllowed41(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery.notPlan().andPlan()); + } + }, + some: { + applyPlan($where, fieldArgs) { + assertAllowed41(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + none: { + applyPlan($where, fieldArgs) { + assertAllowed41(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + aggregates: { + applyPlan($where, fieldArgs) { + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = new PgAggregateConditionStep($where, { + sql, + tableExpression, + alias + }, pgWhereConditionSpecListToSQL); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + } + }, + UpvoteConnection: { + __assertStep: ConnectionStep, + nodes($connection) { + return $connection.nodes(); + }, + edges($connection) { + return $connection.edges(); + }, + pageInfo($connection) { + return $connection.pageInfo(); + }, + totalCount($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + }, + aggregates($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").single(); + }, + groupedAggregates: { + plan($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate"); + }, + args: { + groupBy: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect, input) { + var _a, _b; + const val = input.getRaw().eval(); + if (!Array.isArray(val)) throw new Error("Invalid!"); + for (const group of val) { + const config = getEnumValueConfig(UpvoteGroupBy, group), + plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; + if (typeof plan === "function") plan($pgSelect); + } + return null; + } + }, + having: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect) { + return $pgSelect.havingPlan(); + } + } + } + } + }, + Upvote: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.Upvote.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Upvote.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); + }, + postId($record) { + return $record.get("post_id"); + }, + userId($record) { + return $record.get("user_id"); + }, + createdAt($record) { + return $record.get("created_at"); + }, + updatedAt($record) { + return $record.get("updated_at"); }, post($record) { return pgResource_postPgResource.get({ id: $record.get("post_id") }); }, - user($record) { - return pgResource_userPgResource.get({ - id: $record.get("user_id") - }); + user($record) { + return pgResource_userPgResource.get({ + id: $record.get("user_id") + }); + } + }, + UpvoteEdge: { + __assertStep: assertEdgeCapableStep, + cursor($edge) { + return $edge.cursor(); + }, + node($edge) { + return $edge.node(); + } + }, + PageInfo: { + __assertStep: assertPageInfoCapableStep, + hasNextPage($pageInfo) { + return $pageInfo.hasNextPage(); + }, + hasPreviousPage($pageInfo) { + return $pageInfo.hasPreviousPage(); + }, + startCursor($pageInfo) { + return $pageInfo.startCursor(); + }, + endCursor($pageInfo) { + return $pageInfo.endCursor(); + } + }, + UpvoteAggregates: { + __assertStep: assertPgClassSingleStep, + keys($pgSelectSingle) { + const groups = $pgSelectSingle.getClassStep().getGroups(); + if (groups.length > 0) return $pgSelectSingle.select(sql`json_build_array(${sql.join(groups.map(g => g.fragment), ", ")})`, TYPES.json);else return constant(null); + }, + distinctCount($pgSelectSingle) { + return $pgSelectSingle; + } + }, + UpvoteDistinctCountAggregates: { + rowId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + postId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + createdAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + updatedAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + } + }, + UpvoteGroupBy: { + POST_ID: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan + }, + USER_ID: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan2 + }, + CREATED_AT: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan3 + }, + CREATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan4 + }, + CREATED_AT_TRUNCATED_TO_DAY: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan5 + }, + UPDATED_AT: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan6 + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan7 + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan8 + } + }, + UpvoteHavingInput: { + AND: { + applyPlan($where, input) { + input.apply($where); + return null; + } + }, + OR: { + applyPlan($where, input) { + const $or = new PgOrFilterStep($where); + input.apply($or); + return null; + } + }, + sum: { + applyPlan($having) { + return $having; + } + }, + distinctCount: { + applyPlan($having) { + return $having; + } + }, + min: { + applyPlan($having) { + return $having; + } + }, + max: { + applyPlan($having) { + return $having; + } + }, + average: { + applyPlan($having) { + return $having; + } + }, + stddevSample: { + applyPlan($having) { + return $having; + } + }, + stddevPopulation: { + applyPlan($having) { + return $having; + } + }, + varianceSample: { + applyPlan($having) { + return $having; + } + }, + variancePopulation: { + applyPlan($having) { + return $having; + } + } + }, + UpvoteHavingSumInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + HavingDatetimeFilter: { + equalTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + notEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix2()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + greaterThan: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix3()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + greaterThanOrEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix4()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + lessThan: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix5()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + lessThanOrEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix6()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + } + }, + UpvoteHavingDistinctCountInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingMinInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingMaxInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingAverageInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingStddevSampleInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingStddevPopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingVarianceSampleInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingVariancePopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteOrderBy: { + NATURAL: { + applyPlan() {} + }, + PRIMARY_KEY_ASC: { + applyPlan(step) { + upvoteUniques[0].attributes.forEach(attributeName => { + const attribute = upvoteCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + PRIMARY_KEY_DESC: { + applyPlan(step) { + upvoteUniques[0].attributes.forEach(attributeName => { + const attribute = upvoteCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + ROW_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + ROW_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + POST_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + POST_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USER_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + USER_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + CREATED_AT_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "created_at", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + CREATED_AT_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "created_at", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + UPDATED_AT_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + UPDATED_AT_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + } + }, + UpvoteCondition: { + rowId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.post_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.user_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "created_at", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "created_at", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.created_at.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.updated_at.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true } }, - UpvoteEdge: { + UserOrganizationConnection: { + __assertStep: ConnectionStep, + nodes($connection) { + return $connection.nodes(); + }, + edges($connection) { + return $connection.edges(); + }, + pageInfo($connection) { + return $connection.pageInfo(); + }, + totalCount($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + }, + aggregates($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").single(); + }, + groupedAggregates: { + plan($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate"); + }, + args: { + groupBy: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect, input) { + var _a, _b; + const val = input.getRaw().eval(); + if (!Array.isArray(val)) throw new Error("Invalid!"); + for (const group of val) { + const config = getEnumValueConfig(UserOrganizationGroupBy, group), + plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; + if (typeof plan === "function") plan($pgSelect); + } + return null; + } + }, + having: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect) { + return $pgSelect.havingPlan(); + } + } + } + } + }, + UserOrganizationEdge: { __assertStep: assertEdgeCapableStep, cursor($edge) { return $edge.cursor(); @@ -12974,22 +15675,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $edge.node(); } }, - PageInfo: { - __assertStep: assertPageInfoCapableStep, - hasNextPage($pageInfo) { - return $pageInfo.hasNextPage(); - }, - hasPreviousPage($pageInfo) { - return $pageInfo.hasPreviousPage(); - }, - startCursor($pageInfo) { - return $pageInfo.startCursor(); - }, - endCursor($pageInfo) { - return $pageInfo.endCursor(); - } - }, - UpvoteAggregates: { + UserOrganizationAggregates: { __assertStep: assertPgClassSingleStep, keys($pgSelectSingle) { const groups = $pgSelectSingle.getClassStep().getGroups(); @@ -12999,19 +15685,14 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle; } }, - UpvoteDistinctCountAggregates: { - rowId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, - sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); - return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); - }, - postId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + UserOrganizationDistinctCountAggregates: { + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, - userId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + organizationId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("organization_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, @@ -13019,40 +15700,26 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); - }, - updatedAt($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, - sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); - return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); } }, - UpvoteGroupBy: { - POST_ID: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan - }, + UserOrganizationGroupBy: { USER_ID: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan2 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan + }, + ORGANIZATION_ID: { + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan2 }, CREATED_AT: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan3 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan3 }, CREATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan4 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan4 }, CREATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan5 - }, - UPDATED_AT: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan6 - }, - UPDATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan7 - }, - UPDATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan8 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan5 } }, - UpvoteHavingInput: { + UserOrganizationHavingInput: { AND: { applyPlan($where, input) { input.apply($where); @@ -13095,272 +15762,113 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; applyPlan($having) { return $having; } - }, - stddevPopulation: { - applyPlan($having) { - return $having; - } - }, - varianceSample: { - applyPlan($having) { - return $having; - } - }, - variancePopulation: { - applyPlan($having) { - return $having; - } - } - }, - UpvoteHavingSumInput: { - createdAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - } - }, - HavingDatetimeFilter: { - equalTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - notEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix2()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - greaterThan: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix3()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - greaterThanOrEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix4()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + }, + stddevPopulation: { + applyPlan($having) { + return $having; } }, - lessThan: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix5()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + varianceSample: { + applyPlan($having) { + return $having; } }, - lessThanOrEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix6()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + variancePopulation: { + applyPlan($having) { + return $having; } } }, - UpvoteHavingDistinctCountInput: { + UserOrganizationHavingSumInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingMinInput: { + UserOrganizationHavingDistinctCountInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingMaxInput: { + UserOrganizationHavingMinInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingAverageInput: { + UserOrganizationHavingMaxInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingStddevSampleInput: { + UserOrganizationHavingAverageInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingStddevPopulationInput: { + UserOrganizationHavingStddevSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingVarianceSampleInput: { + UserOrganizationHavingStddevPopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingVariancePopulationInput: { + UserOrganizationHavingVarianceSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } - }, - updatedAt: { + } + }, + UserOrganizationHavingVariancePopulationInput: { + createdAt: { applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteOrderBy: { + UserOrganizationOrderBy: { NATURAL: { applyPlan() {} }, - PRIMARY_KEY_ASC: { - applyPlan(step) { - upvoteUniques[0].attributes.forEach(attributeName => { - const attribute = upvoteCodec.attributes[attributeName]; - step.orderBy({ - codec: attribute.codec, - fragment: sql`${step}.${sql.identifier(attributeName)}`, - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - }); - step.setOrderIsUnique(); - } - }, - PRIMARY_KEY_DESC: { - applyPlan(step) { - upvoteUniques[0].attributes.forEach(attributeName => { - const attribute = upvoteCodec.attributes[attributeName]; - step.orderBy({ - codec: attribute.codec, - fragment: sql`${step}.${sql.identifier(attributeName)}`, - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - }); - step.setOrderIsUnique(); - } - }, - ROW_ID_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "id", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (true) plan.setOrderIsUnique(); - } - }, - ROW_ID_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "id", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (true) plan.setOrderIsUnique(); - } - }, - POST_ID_ASC: { + USER_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "post_id", + attribute: "user_id", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13369,11 +15877,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - POST_ID_DESC: { + USER_ID_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "post_id", + attribute: "user_id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13382,11 +15890,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - USER_ID_ASC: { + ORGANIZATION_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "organization_id", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13395,11 +15903,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - USER_ID_DESC: { + ORGANIZATION_ID_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "organization_id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13433,73 +15941,9 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); if (false) plan.setOrderIsUnique(); } - }, - UPDATED_AT_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "updated_at", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } - }, - UPDATED_AT_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "updated_at", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } } }, - UpvoteCondition: { - rowId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true - }, - postId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "post_id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "post_id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.post_id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true - }, + UserOrganizationCondition: { userId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ @@ -13512,45 +15956,45 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "user_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.user_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.user_id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - createdAt: { + organizationId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "organization_id", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "organization_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.created_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.organization_id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - updatedAt: { + createdAt: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "updated_at", + attribute: "created_at", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "updated_at", + attribute: "created_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.updated_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.created_at.codec)}`; } }); }, @@ -13558,7 +16002,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, - UserOrganizationConnection: { + CommentConnection: { __assertStep: ConnectionStep, nodes($connection) { return $connection.nodes(); @@ -13587,7 +16031,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const val = input.getRaw().eval(); if (!Array.isArray(val)) throw new Error("Invalid!"); for (const group of val) { - const config = getEnumValueConfig(UserOrganizationGroupBy, group), + const config = getEnumValueConfig(CommentGroupBy, group), plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; if (typeof plan === "function") plan($pgSelect); } @@ -13603,7 +16047,42 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UserOrganizationEdge: { + Comment: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.Comment.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Comment.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); + }, + message($record) { + return $record.get("message"); + }, + postId($record) { + return $record.get("post_id"); + }, + userId($record) { + return $record.get("user_id"); + }, + createdAt($record) { + return $record.get("created_at"); + }, + updatedAt($record) { + return $record.get("updated_at"); + }, + post($record) { + return pgResource_postPgResource.get({ + id: $record.get("post_id") + }); + }, + user($record) { + return pgResource_userPgResource.get({ + id: $record.get("user_id") + }); + } + }, + CommentEdge: { __assertStep: assertEdgeCapableStep, cursor($edge) { return $edge.cursor(); @@ -13612,7 +16091,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $edge.node(); } }, - UserOrganizationAggregates: { + CommentAggregates: { __assertStep: assertPgClassSingleStep, keys($pgSelectSingle) { const groups = $pgSelectSingle.getClassStep().getGroups(); @@ -13622,14 +16101,24 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle; } }, - UserOrganizationDistinctCountAggregates: { - userId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + CommentDistinctCountAggregates: { + rowId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, - organizationId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("organization_id")}`, + message($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("message")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.text); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + postId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, @@ -13637,26 +16126,43 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + updatedAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); } }, - UserOrganizationGroupBy: { - USER_ID: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan + CommentGroupBy: { + MESSAGE: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan }, - ORGANIZATION_ID: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan2 + POST_ID: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan2 + }, + USER_ID: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan3 }, CREATED_AT: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan3 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan4 }, CREATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan4 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan5 }, CREATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan5 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan6 + }, + UPDATED_AT: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan7 + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan8 + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan9 } }, - UserOrganizationHavingInput: { + CommentHavingInput: { AND: { applyPlan($where, input) { input.apply($where); @@ -13716,90 +16222,263 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UserOrganizationHavingSumInput: { + CommentHavingSumInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingDistinctCountInput: { + CommentHavingDistinctCountInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingMinInput: { + CommentHavingMinInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingMaxInput: { + CommentHavingMaxInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingAverageInput: { + CommentHavingAverageInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingStddevSampleInput: { + CommentHavingStddevSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingStddevPopulationInput: { + CommentHavingStddevPopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingVarianceSampleInput: { + CommentHavingVarianceSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + CommentHavingVariancePopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } - } - }, - UserOrganizationHavingVariancePopulationInput: { - createdAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + CommentOrderBy: { + NATURAL: { + applyPlan() {} + }, + PRIMARY_KEY_ASC: { + applyPlan(step) { + commentUniques[0].attributes.forEach(attributeName => { + const attribute = commentCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + PRIMARY_KEY_DESC: { + applyPlan(step) { + commentUniques[0].attributes.forEach(attributeName => { + const attribute = commentCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + ROW_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + ROW_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + MESSAGE_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "message", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + MESSAGE_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "message", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POST_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POST_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); } - } - }, - UserOrganizationOrderBy: { - NATURAL: { - applyPlan() {} }, USER_ID_ASC: { applyPlan(plan) { @@ -13811,7 +16490,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (true) plan.setOrderIsUnique(); + if (false) plan.setOrderIsUnique(); } }, USER_ID_DESC: { @@ -13824,14 +16503,14 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (true) plan.setOrderIsUnique(); + if (false) plan.setOrderIsUnique(); } }, - ORGANIZATION_ID_ASC: { + CREATED_AT_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "organization_id", + attribute: "created_at", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13840,11 +16519,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - ORGANIZATION_ID_DESC: { + CREATED_AT_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "organization_id", + attribute: "created_at", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13853,11 +16532,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - CREATED_AT_ASC: { + UPDATED_AT_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "created_at", + attribute: "updated_at", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13866,11 +16545,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - CREATED_AT_DESC: { + UPDATED_AT_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "created_at", + attribute: "updated_at", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -13880,39 +16559,77 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UserOrganizationCondition: { - userId: { + CommentCondition: { + rowId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "user_id", + attribute: "id", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "user_id", + attribute: "id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.user_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - organizationId: { + message: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "organization_id", + attribute: "message", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "organization_id", + attribute: "message", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.organization_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.message.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.post_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.user_id.codec)}`; } }); }, @@ -13931,7 +16648,26 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "created_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.created_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.created_at.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.updated_at.codec)}`; } }); }, @@ -14777,8 +17513,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14797,8 +17533,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14818,8 +17554,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14840,8 +17576,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14862,8 +17598,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14884,8 +17620,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14906,8 +17642,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14928,8 +17664,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14950,8 +17686,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14972,8 +17708,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -14994,8 +17730,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15016,8 +17752,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15038,8 +17774,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15060,8 +17796,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15082,8 +17818,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15104,8 +17840,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation2.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation2.remoteAttributes[i]; + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15761,8 +18497,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15781,8 +18517,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15802,8 +18538,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15824,8 +18560,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15846,8 +18582,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15868,8 +18604,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15890,8 +18626,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15912,8 +18648,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15934,8 +18670,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15956,8 +18692,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -15978,8 +18714,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16000,8 +18736,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16022,8 +18758,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16044,8 +18780,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16066,8 +18802,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16088,8 +18824,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16110,8 +18846,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16132,8 +18868,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16153,8 +18889,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16173,8 +18909,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16194,8 +18930,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16216,8 +18952,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16238,8 +18974,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16260,8 +18996,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16282,8 +19018,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16304,8 +19040,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -16860,889 +19596,1193 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (false) plan.setOrderIsUnique(); + if (false) plan.setOrderIsUnique(); + } + }, + HIDRA_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "hidra_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + HIDRA_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "hidra_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USERNAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "username", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USERNAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "username", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + FIRST_NAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "first_name", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + FIRST_NAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "first_name", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + LAST_NAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "last_name", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + LAST_NAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "last_name", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POSTS_COUNT_ASC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "ASC" + }); + } + }, + POSTS_COUNT_DESC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "DESC" + }); + } + }, + POSTS_DISTINCT_COUNT_ROW_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + direction: "ASC" + }); + } + }, + POSTS_DISTINCT_COUNT_ROW_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + direction: "DESC" + }); + } + }, + POSTS_DISTINCT_COUNT_TITLE_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + direction: "ASC" + }); + } + }, + POSTS_DISTINCT_COUNT_TITLE_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + direction: "DESC" + }); } }, - HIDRA_ID_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "hidra_id", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_DESCRIPTION_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + direction: "ASC" }); - if (true) plan.setOrderIsUnique(); } }, - HIDRA_ID_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "hidra_id", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_DESCRIPTION_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + direction: "DESC" }); - if (true) plan.setOrderIsUnique(); } }, - USERNAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "username", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_PROJECT_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + direction: "ASC" }); - if (true) plan.setOrderIsUnique(); } }, - USERNAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "username", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_PROJECT_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + direction: "DESC" }); - if (true) plan.setOrderIsUnique(); } }, - FIRST_NAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "first_name", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_USER_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + direction: "ASC" }); - if (false) plan.setOrderIsUnique(); } }, - FIRST_NAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "first_name", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_USER_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + direction: "DESC" }); - if (false) plan.setOrderIsUnique(); } }, - LAST_NAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "last_name", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_CREATED_AT_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + direction: "ASC" }); - if (false) plan.setOrderIsUnique(); } }, - LAST_NAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "last_name", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_CREATED_AT_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + direction: "DESC" }); - if (false) plan.setOrderIsUnique(); } }, - POSTS_COUNT_ASC: { + POSTS_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, direction: "ASC" }); } }, - POSTS_COUNT_DESC: { + POSTS_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_ROW_ID_ASC: { + UPVOTES_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_upvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_ROW_ID_DESC: { + UPVOTES_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_upvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_TITLE_ASC: { + UPVOTES_DISTINCT_COUNT_ROW_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_TITLE_DESC: { + UPVOTES_DISTINCT_COUNT_ROW_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_DESCRIPTION_ASC: { + UPVOTES_DISTINCT_COUNT_POST_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_DESCRIPTION_DESC: { + UPVOTES_DISTINCT_COUNT_POST_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_PROJECT_ID_ASC: { + UPVOTES_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_PROJECT_ID_DESC: { + UPVOTES_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_USER_ID_ASC: { + UPVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_USER_ID_DESC: { + UPVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_CREATED_AT_ASC: { + UPVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_CREATED_AT_DESC: { + UPVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_UPDATED_AT_ASC: { + USER_ORGANIZATIONS_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${resource_user_organizationPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_UPDATED_AT_DESC: { + USER_ORGANIZATIONS_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${resource_user_organizationPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - UPVOTES_COUNT_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, direction: "ASC" }); } }, - UPVOTES_COUNT_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_ROW_ID_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_ROW_ID_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_POST_ID_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_POST_ID_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_USER_ID_ASC: { + COMMENTS_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_USER_ID_DESC: { + COMMENTS_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { + COMMENTS_DISTINCT_COUNT_ROW_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { + COMMENTS_DISTINCT_COUNT_ROW_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { + COMMENTS_DISTINCT_COUNT_MESSAGE_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { + COMMENTS_DISTINCT_COUNT_MESSAGE_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_COUNT_ASC: { + COMMENTS_DISTINCT_COUNT_POST_ID_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${resource_user_organizationPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_COUNT_DESC: { + COMMENTS_DISTINCT_COUNT_POST_ID_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${resource_user_organizationPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_ASC: { + COMMENTS_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_DESC: { + COMMENTS_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_ASC: { + COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_DESC: { + COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_ASC: { + COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_DESC: { + COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, direction: "DESC" }); } @@ -17936,6 +20976,23 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + createComment: { + plan(_, args) { + const plan = object({ + result: pgInsertSingle(pgResource_commentPgResource, Object.create(null)) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + autoApplyAfterParentPlan: true, + applyPlan(_, $object) { + return $object; + } + } + } + }, createPost: { plan(_, args) { const plan = object({ @@ -18129,10 +21186,44 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + updateCommentById: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_commentPgResource, specFromArgs3(args)) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + updateComment: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_commentPgResource, { + id: args.get(['input', "rowId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, updatePostById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_postPgResource, specFromArgs3(args)) + result: pgUpdateSingle(pgResource_postPgResource, specFromArgs4(args)) }); args.apply(plan); return plan; @@ -18166,7 +21257,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateUserById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_userPgResource, specFromArgs4(args)) + result: pgUpdateSingle(pgResource_userPgResource, specFromArgs5(args)) }); args.apply(plan); return plan; @@ -18236,7 +21327,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateProjectById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_projectPgResource, specFromArgs5(args)) + result: pgUpdateSingle(pgResource_projectPgResource, specFromArgs6(args)) }); args.apply(plan); return plan; @@ -18326,7 +21417,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteUpvoteById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_upvotePgResource, specFromArgs6(args)) + result: pgDeleteSingle(pgResource_upvotePgResource, specFromArgs7(args)) }); args.apply(plan); return plan; @@ -18379,7 +21470,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteOrganizationById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_organizationPgResource, specFromArgs7(args)) + result: pgDeleteSingle(pgResource_organizationPgResource, specFromArgs8(args)) }); args.apply(plan); return plan; @@ -18446,10 +21537,44 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + deleteCommentById: { + plan(_$root, args) { + const plan = object({ + result: pgDeleteSingle(pgResource_commentPgResource, specFromArgs9(args)) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + deleteComment: { + plan(_$root, args) { + const plan = object({ + result: pgDeleteSingle(pgResource_commentPgResource, { + id: args.get(['input', "rowId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, deletePostById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_postPgResource, specFromArgs8(args)) + result: pgDeleteSingle(pgResource_postPgResource, specFromArgs10(args)) }); args.apply(plan); return plan; @@ -18483,7 +21608,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteUserById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_userPgResource, specFromArgs9(args)) + result: pgDeleteSingle(pgResource_userPgResource, specFromArgs11(args)) }); args.apply(plan); return plan; @@ -18553,7 +21678,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteProjectById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_projectPgResource, specFromArgs10(args)) + result: pgDeleteSingle(pgResource_projectPgResource, specFromArgs12(args)) }); args.apply(plan); return plan; @@ -18852,6 +21977,102 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, + CreateCommentPayload: { + __assertStep: assertExecutableStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + comment($object) { + return $object.get("result"); + }, + query() { + return rootValue(); + }, + commentEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = commentUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_commentPgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + CreateCommentInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + }, + autoApplyAfterParentApplyPlan: true + }, + comment: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + }, + autoApplyAfterParentApplyPlan: true + } + }, + CommentInput: { + "__inputPlan": function CommentInput_inputPlan() { + return object(Object.create(null)); + }, + rowId: { + applyPlan($insert, val) { + $insert.set("id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + message: { + applyPlan($insert, val) { + $insert.set("message", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($insert, val) { + $insert.set("post_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($insert, val) { + $insert.set("user_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($insert, val) { + $insert.set("created_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($insert, val) { + $insert.set("updated_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + } + }, CreatePostPayload: { __assertStep: assertExecutableStep, clientMutationId($mutation) { @@ -19462,6 +22683,114 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + UpdateCommentPayload: { + __assertStep: ObjectStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + comment($object) { + return $object.get("result"); + }, + query() { + return rootValue(); + }, + commentEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = commentUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_commentPgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + UpdateCommentByIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + id: undefined, + patch: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + } + } + }, + CommentPatch: { + "__inputPlan": function CommentPatch_inputPlan() { + return object(Object.create(null)); + }, + rowId: { + applyPlan($insert, val) { + $insert.set("id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + message: { + applyPlan($insert, val) { + $insert.set("message", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($insert, val) { + $insert.set("post_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($insert, val) { + $insert.set("user_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($insert, val) { + $insert.set("created_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($insert, val) { + $insert.set("updated_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + } + }, + UpdateCommentInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + rowId: undefined, + patch: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + } + } + }, UpdatePostPayload: { __assertStep: ObjectStep, clientMutationId($mutation) { @@ -20025,6 +23354,62 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, slug: undefined }, + DeleteCommentPayload: { + __assertStep: ObjectStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + comment($object) { + return $object.get("result"); + }, + deletedCommentId($object) { + const $record = $object.getStepForKey("result"), + specifier = nodeIdHandlerByTypeName.Comment.plan($record); + return lambda(specifier, nodeIdCodecs_base64JSON_base64JSON.encode); + }, + query() { + return rootValue(); + }, + commentEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = commentUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_commentPgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("CommentOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + DeleteCommentByIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + id: undefined + }, + DeleteCommentInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + rowId: undefined + }, DeletePostPayload: { __assertStep: ObjectStep, clientMutationId($mutation) { diff --git a/src/lib/drizzle/migrations/0002_high_ender_wiggin.sql b/src/lib/drizzle/migrations/0002_high_ender_wiggin.sql new file mode 100644 index 0000000..4de866e --- /dev/null +++ b/src/lib/drizzle/migrations/0002_high_ender_wiggin.sql @@ -0,0 +1,11 @@ +CREATE TABLE "comment" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "message" text, + "post_id" uuid NOT NULL, + "user_id" uuid NOT NULL, + "created_at" timestamp(6) with time zone DEFAULT now(), + "updated_at" timestamp(6) with time zone DEFAULT now() +); +--> statement-breakpoint +ALTER TABLE "comment" ADD CONSTRAINT "comment_post_id_post_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."post"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "comment" ADD CONSTRAINT "comment_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/src/lib/drizzle/migrations/meta/0002_snapshot.json b/src/lib/drizzle/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..5f07cbf --- /dev/null +++ b/src/lib/drizzle/migrations/meta/0002_snapshot.json @@ -0,0 +1,561 @@ +{ + "id": "a07ce84b-3633-4339-9d3f-3f1ea87fd405", + "prevId": "7fb3a1e8-4855-4cf2-a51f-829a6cb9943e", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.comment": { + "name": "comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "post_id": { + "name": "post_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "comment_post_id_post_id_fk": { + "name": "comment_post_id_post_id_fk", + "tableFrom": "comment", + "tableTo": "post", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_user_id_user_id_fk": { + "name": "comment_user_id_user_id_fk", + "tableFrom": "comment", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_name_unique": { + "name": "organization_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + }, + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.post": { + "name": "post", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "post_project_id_project_id_fk": { + "name": "post_project_id_project_id_fk", + "tableFrom": "post", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "post_user_id_user_id_fk": { + "name": "post_user_id_user_id_fk", + "tableFrom": "post", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project": { + "name": "project", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "project_organization_id_organization_id_fk": { + "name": "project_organization_id_organization_id_fk", + "tableFrom": "project", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_name_unique": { + "name": "project_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + }, + "project_slug_organizationId_unique": { + "name": "project_slug_organizationId_unique", + "nullsNotDistinct": false, + "columns": [ + "slug", + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.upvote": { + "name": "upvote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "post_id": { + "name": "post_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "upvote_post_id_post_id_fk": { + "name": "upvote_post_id_post_id_fk", + "tableFrom": "upvote", + "tableTo": "post", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "upvote_user_id_user_id_fk": { + "name": "upvote_user_id_user_id_fk", + "tableFrom": "upvote", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "upvote_postId_userId_unique": { + "name": "upvote_postId_userId_unique", + "nullsNotDistinct": false, + "columns": [ + "post_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "hidra_id": { + "name": "hidra_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_hidraId_unique": { + "name": "user_hidraId_unique", + "nullsNotDistinct": false, + "columns": [ + "hidra_id" + ] + }, + "user_username_unique": { + "name": "user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_organization": { + "name": "user_organization", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_organization_user_id_user_id_fk": { + "name": "user_organization_user_id_user_id_fk", + "tableFrom": "user_organization", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_organization_organization_id_organization_id_fk": { + "name": "user_organization_organization_id_organization_id_fk", + "tableFrom": "user_organization", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_organization_userId_organizationId_unique": { + "name": "user_organization_userId_organizationId_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/src/lib/drizzle/migrations/meta/_journal.json b/src/lib/drizzle/migrations/meta/_journal.json index 9555aaf..323a2fd 100644 --- a/src/lib/drizzle/migrations/meta/_journal.json +++ b/src/lib/drizzle/migrations/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1735577973197, "tag": "0001_thankful_shinko_yamashiro", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1735611260906, + "tag": "0002_high_ender_wiggin", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/lib/drizzle/schema/comment.table.ts b/src/lib/drizzle/schema/comment.table.ts new file mode 100644 index 0000000..42f7fba --- /dev/null +++ b/src/lib/drizzle/schema/comment.table.ts @@ -0,0 +1,48 @@ +import { relations } from "drizzle-orm"; +import { pgTable, text, uuid } from "drizzle-orm/pg-core"; + +import { defaultDate, defaultId } from "./constants"; +import { posts } from "./post.table"; +import { users } from "./user.table"; + +import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; + +/** + * Comment table. Comments reperesent feedback item comments. + */ +export const comments = pgTable("comment", { + id: defaultId(), + message: text(), + postId: uuid() + .notNull() + .references(() => posts.id, { + onDelete: "cascade", + }), + userId: uuid() + .notNull() + .references(() => users.id, { + onDelete: "cascade", + }), + createdAt: defaultDate(), + updatedAt: defaultDate(), +}); + +/** + * Relations for the comment table. + */ +export const commentRelations = relations(comments, ({ one }) => ({ + post: one(posts, { + fields: [comments.postId], + references: [posts.id], + }), + user: one(users, { + fields: [comments.userId], + references: [users.id], + }), +})); + +/** + * Type helpers related to the comment table. + */ +export type InsertComment = InferInsertModel; +export type SelectComment = InferSelectModel; diff --git a/src/lib/drizzle/schema/index.ts b/src/lib/drizzle/schema/index.ts index ca9592c..2728aec 100644 --- a/src/lib/drizzle/schema/index.ts +++ b/src/lib/drizzle/schema/index.ts @@ -1,3 +1,4 @@ +export * from "./comment.table"; export * from "./organization.table"; export * from "./post.table"; export * from "./project.table"; diff --git a/src/lib/drizzle/schema/post.table.ts b/src/lib/drizzle/schema/post.table.ts index 03db956..c961064 100644 --- a/src/lib/drizzle/schema/post.table.ts +++ b/src/lib/drizzle/schema/post.table.ts @@ -1,6 +1,7 @@ import { relations } from "drizzle-orm"; import { pgTable, text, uuid } from "drizzle-orm/pg-core"; +import { comments } from "./comment.table"; import { defaultDate, defaultId } from "./constants"; import { projects } from "./project.table"; import { upvotes } from "./upvote.table"; @@ -41,6 +42,7 @@ export const postRelations = relations(posts, ({ one, many }) => ({ fields: [posts.userId], references: [users.id], }), + comments: many(comments), upvotes: many(upvotes), })); diff --git a/src/scripts/seedDatabase.ts b/src/scripts/seedDatabase.ts index 181507b..3a65f27 100644 --- a/src/scripts/seedDatabase.ts +++ b/src/scripts/seedDatabase.ts @@ -22,22 +22,26 @@ const seedDatabase = async () => { await seed(db, schema).refine((f) => ({ organizations: { - count: 400, + count: 200, columns: { name: f.companyName(), }, + with: { + projects: 50, + }, }, projects: { - count: 2000, columns: { description: f.loremIpsum(), slug: f.string({ isUnique: true, }), }, + with: { + posts: 20, + }, }, posts: { - count: 10000, columns: { title: f.companyName(), description: f.loremIpsum(), @@ -46,16 +50,24 @@ const seedDatabase = async () => { maxDate: dayjs(new Date()).format("YYYY-MM-DD"), }), }, + with: { + comments: 10, + }, }, users: { count: 500, }, usersToOrganizations: { - count: 50, + count: 100, }, upvotes: { count: 1000, }, + comments: { + columns: { + message: f.loremIpsum(), + }, + }, })); console.log("Database has been seeded successfully!"); diff --git a/src/server.ts b/src/server.ts index d19758f..1362770 100644 --- a/src/server.ts +++ b/src/server.ts @@ -38,7 +38,7 @@ app.use( origin: isProdEnv ? appConfig.url : "http://localhost:3000", credentials: true, allowMethods: ["POST"], - }), + }) ); // mount GraphQL API @@ -47,7 +47,7 @@ app.use("/graphql", async (c) => yoga.handle(c.req.raw, {})); // GraphQL Yoga suppresses logging the startup message in production environments by default if (isProdEnv) console.log( - `🚀 ${appConfig.name} GraphQL API running at http://${HOST}:${PORT}`, + `🚀 ${appConfig.name} GraphQL API running at http://${HOST}:${PORT}` ); export default { From a6d8cb2b91a92fa228d9b4a6123a5ebff79cc460 Mon Sep 17 00:00:00 2001 From: hobbescodes <87732294+hobbescodes@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:28:11 -0600 Subject: [PATCH 2/7] feature(schema): add downvotes table, adjust relations --- src/generated/graphql/schema.executable.ts | 6299 +++++++++++++---- .../migrations/0003_medical_paper_doll.sql | 11 + .../migrations/meta/0003_snapshot.json | 643 ++ src/lib/drizzle/migrations/meta/_journal.json | 7 + src/lib/drizzle/schema/downvote.table.ts | 51 + src/lib/drizzle/schema/index.ts | 1 + src/lib/drizzle/schema/post.table.ts | 2 + src/lib/drizzle/schema/user.table.ts | 4 + src/scripts/seedDatabase.ts | 7 +- 9 files changed, 5514 insertions(+), 1511 deletions(-) create mode 100644 src/lib/drizzle/migrations/0003_medical_paper_doll.sql create mode 100644 src/lib/drizzle/migrations/meta/0003_snapshot.json create mode 100644 src/lib/drizzle/schema/downvote.table.ts diff --git a/src/generated/graphql/schema.executable.ts b/src/generated/graphql/schema.executable.ts index 7dce1b6..f9a3768 100644 --- a/src/generated/graphql/schema.executable.ts +++ b/src/generated/graphql/schema.executable.ts @@ -132,6 +132,86 @@ const spec_userOrganization = { executor: executor }; const userOrganizationCodec = recordCodec(spec_userOrganization); +const downvoteIdentifier = sql.identifier("public", "downvote"); +const spec_downvote = { + name: "downvote", + identifier: downvoteIdentifier, + attributes: Object.assign(Object.create(null), { + id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + post_id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: false, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + user_id: { + description: undefined, + codec: TYPES.uuid, + notNull: true, + hasDefault: false, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + created_at: { + description: undefined, + codec: TYPES.timestamptz, + notNull: false, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + }, + updated_at: { + description: undefined, + codec: TYPES.timestamptz, + notNull: false, + hasDefault: true, + extensions: { + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true + } + } + }), + description: undefined, + extensions: { + oid: "78725", + isTableLike: true, + pg: { + serviceName: "main", + schemaName: "public", + name: "downvote" + }, + tags: Object.create(null) + }, + executor: executor +}; +const downvoteCodec = recordCodec(spec_downvote); const upvoteIdentifier = sql.identifier("public", "upvote"); const spec_upvote = { name: "upvote", @@ -741,6 +821,47 @@ const registryConfig_pgResources_user_organization_user_organization = { canDelete: true } }; +const downvoteUniques = [{ + isPrimary: true, + attributes: ["id"], + description: undefined, + extensions: { + tags: Object.create(null) + } +}, { + isPrimary: false, + attributes: ["post_id", "user_id"], + description: undefined, + extensions: { + tags: Object.create(null) + } +}]; +const registryConfig_pgResources_downvote_downvote = { + executor: executor, + name: "downvote", + identifier: "main.public.downvote", + from: downvoteIdentifier, + codec: downvoteCodec, + uniques: downvoteUniques, + isVirtual: false, + description: undefined, + extensions: { + description: undefined, + pg: { + serviceName: "main", + schemaName: "public", + name: "downvote" + }, + isInsertable: true, + isUpdatable: true, + isDeletable: true, + tags: {}, + canSelect: true, + canInsert: true, + canUpdate: true, + canDelete: true + } +}; const upvoteUniques = [{ isPrimary: true, attributes: ["id"], @@ -1002,6 +1123,7 @@ const registryConfig = { userOrganization: userOrganizationCodec, uuid: TYPES.uuid, timestamptz: TYPES.timestamptz, + downvote: downvoteCodec, upvote: upvoteCodec, organization: organizationCodec, text: TYPES.text, @@ -1012,6 +1134,7 @@ const registryConfig = { }), pgResources: Object.assign(Object.create(null), { user_organization: registryConfig_pgResources_user_organization_user_organization, + downvote: registryConfig_pgResources_downvote_downvote, upvote: registryConfig_pgResources_upvote_upvote, organization: registryConfig_pgResources_organization_organization, comment: registryConfig_pgResources_comment_comment, @@ -1052,6 +1175,38 @@ const registryConfig = { } } }), + downvote: Object.assign(Object.create(null), { + postByMyPostId: { + localCodec: downvoteCodec, + remoteResourceOptions: registryConfig_pgResources_post_post, + localCodecPolymorphicTypes: undefined, + localAttributes: ["post_id"], + remoteAttributes: ["id"], + isUnique: true, + isReferencee: false, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } + }, + userByMyUserId: { + localCodec: downvoteCodec, + remoteResourceOptions: registryConfig_pgResources_user_user, + localCodecPolymorphicTypes: undefined, + localAttributes: ["user_id"], + remoteAttributes: ["id"], + isUnique: true, + isReferencee: false, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } + } + }), organization: Object.assign(Object.create(null), { projectsByTheirOrganizationId: { localCodec: organizationCodec, @@ -1144,6 +1299,21 @@ const registryConfig = { behavior: [] } } + }, + downvotesByTheirPostId: { + localCodec: postCodec, + remoteResourceOptions: registryConfig_pgResources_downvote_downvote, + localCodecPolymorphicTypes: undefined, + localAttributes: ["id"], + remoteAttributes: ["post_id"], + isUnique: false, + isReferencee: true, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } } }), project: Object.assign(Object.create(null), { @@ -1270,6 +1440,21 @@ const registryConfig = { behavior: [] } } + }, + downvotesByTheirUserId: { + localCodec: userCodec, + remoteResourceOptions: registryConfig_pgResources_downvote_downvote, + localCodecPolymorphicTypes: undefined, + localAttributes: ["id"], + remoteAttributes: ["user_id"], + isUnique: false, + isReferencee: true, + description: undefined, + extensions: { + tags: { + behavior: [] + } + } } }), userOrganization: Object.assign(Object.create(null), { @@ -1307,6 +1492,7 @@ const registryConfig = { }) }; const registry = makeRegistry(registryConfig); +const pgResource_downvotePgResource = registry.pgResources["downvote"]; const pgResource_upvotePgResource = registry.pgResources["upvote"]; const pgResource_organizationPgResource = registry.pgResources["organization"]; const pgResource_commentPgResource = registry.pgResources["comment"]; @@ -1315,6 +1501,25 @@ const pgResource_userPgResource = registry.pgResources["user"]; const pgResource_projectPgResource = registry.pgResources["project"]; const nodeIdHandlerByTypeName = Object.assign(Object.create(null), { Query: handler, + Downvote: { + typeName: "Downvote", + codec: nodeIdCodecs_base64JSON_base64JSON, + deprecationReason: undefined, + plan($record) { + return list([constant("Downvote", false), $record.get("id")]); + }, + getSpec($list) { + return { + id: inhibitOnNull(access($list, [1])) + }; + }, + get(spec) { + return pgResource_downvotePgResource.get(spec); + }, + match(obj) { + return obj[0] === "Downvote"; + } + }, Upvote: { typeName: "Upvote", codec: nodeIdCodecs_base64JSON_base64JSON, @@ -1450,7 +1655,7 @@ const fetcher = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.Upvote); +})(nodeIdHandlerByTypeName.Downvote); const fetcher2 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1458,7 +1663,7 @@ const fetcher2 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.Organization); +})(nodeIdHandlerByTypeName.Upvote); const fetcher3 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1466,7 +1671,7 @@ const fetcher3 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.Comment); +})(nodeIdHandlerByTypeName.Organization); const fetcher4 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1474,7 +1679,7 @@ const fetcher4 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.Post); +})(nodeIdHandlerByTypeName.Comment); const fetcher5 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1482,7 +1687,7 @@ const fetcher5 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; -})(nodeIdHandlerByTypeName.User); +})(nodeIdHandlerByTypeName.Post); const fetcher6 = (handler => { const fn = $nodeId => { const $decoded = lambda($nodeId, specForHandler(handler)); @@ -1490,6 +1695,14 @@ const fetcher6 = (handler => { }; fn.deprecationReason = handler.deprecationReason; return fn; +})(nodeIdHandlerByTypeName.User); +const fetcher7 = (handler => { + const fn = $nodeId => { + const $decoded = lambda($nodeId, specForHandler(handler)); + return handler.get(handler.getSpec($decoded)); + }; + fn.deprecationReason = handler.deprecationReason; + return fn; })(nodeIdHandlerByTypeName.Project); const applyOrderToPlan = ($select, $value, TableOrderByType) => { if (!("evalLength" in $value)) return; @@ -1590,6 +1803,18 @@ function assertAllowed7(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } +function assertAllowed8(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} function UUIDSerialize(value) { return "" + value; } @@ -1597,7 +1822,7 @@ const coerce = string => { if (!/^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i.test(string)) throw new GraphQLError("Invalid UUID, expected 32 hexadecimal characters, optionally with hypens"); return string; }; -function assertAllowed8(fieldArgs, mode) { +function assertAllowed9(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1609,7 +1834,7 @@ function assertAllowed8(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed9(fieldArgs, mode) { +function assertAllowed10(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1775,7 +2000,7 @@ export const ProjectGroupBy = new GraphQLEnumType({ } }) }); -function assertAllowed10(fieldArgs, mode) { +function assertAllowed11(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1923,7 +2148,7 @@ export const PostGroupBy = new GraphQLEnumType({ } }) }); -function assertAllowed11(fieldArgs, mode) { +function assertAllowed12(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1935,7 +2160,7 @@ function assertAllowed11(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed12(fieldArgs, mode) { +function assertAllowed13(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1947,7 +2172,7 @@ function assertAllowed12(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed13(fieldArgs, mode) { +function assertAllowed14(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1959,7 +2184,7 @@ function assertAllowed13(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed14(fieldArgs, mode) { +function assertAllowed15(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1971,7 +2196,7 @@ function assertAllowed14(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed15(fieldArgs, mode) { +function assertAllowed16(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -1983,7 +2208,31 @@ function assertAllowed15(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed16(fieldArgs, mode) { +function assertAllowed17(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed18(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed19(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2014,6 +2263,7 @@ const aggregateSpec = { } }; const relation2 = registry.pgRelations["post"]["commentsByTheirPostId"]; +const relation3 = registry.pgRelations["post"]["downvotesByTheirPostId"]; const colSpec = { fieldName: "rowId", attributeName: "id", @@ -2049,7 +2299,7 @@ const colSpec7 = { attributeName: "updated_at", attribute: spec_post.attributes.updated_at }; -function assertAllowed17(fieldArgs, mode) { +function assertAllowed20(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2061,7 +2311,7 @@ function assertAllowed17(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed18(fieldArgs, mode) { +function assertAllowed21(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2073,7 +2323,7 @@ function assertAllowed18(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed19(fieldArgs, mode) { +function assertAllowed22(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2507,7 +2757,7 @@ const resolve46 = (i, v) => sql`${i} < ${v}`; const resolve47 = (i, v) => sql`${i} <= ${v}`; const resolve48 = (i, v) => sql`${i} > ${v}`; const resolve49 = (i, v) => sql`${i} >= ${v}`; -function assertAllowed20(fieldArgs, mode) { +function assertAllowed23(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2607,7 +2857,7 @@ const colSpec12 = { attributeName: "updated_at", attribute: spec_upvote.attributes.updated_at }; -function assertAllowed21(fieldArgs, mode) { +function assertAllowed24(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2619,7 +2869,7 @@ function assertAllowed21(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed22(fieldArgs, mode) { +function assertAllowed25(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2666,7 +2916,7 @@ const colSpec19 = { attributeName: "last_name", attribute: spec_user.attributes.last_name }; -function assertAllowed23(fieldArgs, mode) { +function assertAllowed26(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2678,7 +2928,7 @@ function assertAllowed23(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed24(fieldArgs, mode) { +function assertAllowed27(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2690,7 +2940,7 @@ function assertAllowed24(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed25(fieldArgs, mode) { +function assertAllowed28(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2752,7 +3002,7 @@ const resolve57 = (i, v) => sql`${i} < ${v}`; const resolve58 = (i, v) => sql`${i} <= ${v}`; const resolve59 = (i, v) => sql`${i} > ${v}`; const resolve60 = (i, v) => sql`${i} >= ${v}`; -function assertAllowed26(fieldArgs, mode) { +function assertAllowed29(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2764,7 +3014,7 @@ function assertAllowed26(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed27(fieldArgs, mode) { +function assertAllowed30(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2791,7 +3041,7 @@ const colSpec22 = { attributeName: "created_at", attribute: spec_userOrganization.attributes.created_at }; -function assertAllowed28(fieldArgs, mode) { +function assertAllowed31(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2803,7 +3053,7 @@ function assertAllowed28(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed29(fieldArgs, mode) { +function assertAllowed32(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2840,7 +3090,7 @@ const colSpec27 = { attributeName: "updated_at", attribute: spec_organization.attributes.updated_at }; -function assertAllowed30(fieldArgs, mode) { +function assertAllowed33(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2852,7 +3102,7 @@ function assertAllowed30(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed31(fieldArgs, mode) { +function assertAllowed34(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2864,7 +3114,7 @@ function assertAllowed31(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed32(fieldArgs, mode) { +function assertAllowed35(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2916,7 +3166,7 @@ const colSpec35 = { attributeName: "updated_at", attribute: spec_project.attributes.updated_at }; -function assertAllowed33(fieldArgs, mode) { +function assertAllowed36(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2928,7 +3178,7 @@ function assertAllowed33(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed34(fieldArgs, mode) { +function assertAllowed37(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2940,7 +3190,7 @@ function assertAllowed34(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed35(fieldArgs, mode) { +function assertAllowed38(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2952,7 +3202,7 @@ function assertAllowed35(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed36(fieldArgs, mode) { +function assertAllowed39(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2964,7 +3214,7 @@ function assertAllowed36(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed37(fieldArgs, mode) { +function assertAllowed40(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -2976,7 +3226,7 @@ function assertAllowed37(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed38(fieldArgs, mode) { +function assertAllowed41(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -3018,7 +3268,7 @@ const colSpec41 = { attributeName: "updated_at", attribute: spec_comment.attributes.updated_at }; -function assertAllowed39(fieldArgs, mode) { +function assertAllowed42(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -3030,7 +3280,7 @@ function assertAllowed39(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed40(fieldArgs, mode) { +function assertAllowed43(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -3042,7 +3292,80 @@ function assertAllowed40(fieldArgs, mode) { } if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); } -function assertAllowed41(fieldArgs, mode) { +function assertAllowed44(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +const colSpec42 = { + fieldName: "rowId", + attributeName: "id", + attribute: spec_downvote.attributes.id +}; +const colSpec43 = { + fieldName: "postId", + attributeName: "post_id", + attribute: spec_downvote.attributes.post_id +}; +const colSpec44 = { + fieldName: "userId", + attributeName: "user_id", + attribute: spec_downvote.attributes.user_id +}; +const colSpec45 = { + fieldName: "createdAt", + attributeName: "created_at", + attribute: spec_downvote.attributes.created_at +}; +const colSpec46 = { + fieldName: "updatedAt", + attributeName: "updated_at", + attribute: spec_downvote.attributes.updated_at +}; +function assertAllowed45(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed46(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed47(fieldArgs, mode) { + const $raw = fieldArgs.getRaw(); + if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (mode === "list" && !false && "evalLength" in $raw) { + const l = $raw.evalLength(); + if (l != null) for (let i = 0; i < l; i++) { + const $entry = $raw.at(i); + if ("evalIsEmpty" in $entry && $entry.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + } + } + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); +} +function assertAllowed48(fieldArgs, mode) { const $raw = fieldArgs.getRaw(); if (mode === "object" && !false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); if (mode === "list" && !false && "evalLength" in $raw) { @@ -3510,7 +3833,117 @@ export const CommentGroupBy = new GraphQLEnumType({ } }) }); -const relation3 = registry.pgRelations["project"]["postsByTheirProjectId"]; +function DownvoteGroupBy_extensions_grafast_applyPlan($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("post_id")}` + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan2($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("user_id")}` + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan3($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan4($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("created_at")}`) + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan5($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec2.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("created_at")}`) + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan6($pgSelect) { + $pgSelect.groupBy({ + fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("updated_at")}` + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan7($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("updated_at")}`) + }); +} +function DownvoteGroupBy_extensions_grafast_applyPlan8($pgSelect) { + $pgSelect.groupBy({ + fragment: aggregateGroupBySpec2.sqlWrap(sql`${$pgSelect.alias}.${sql.identifier("updated_at")}`) + }); +} +export const DownvoteGroupBy = new GraphQLEnumType({ + name: "DownvoteGroupBy", + description: "Grouping methods for `Downvote` for usage during aggregation.", + values: Object.assign(Object.create(null), { + POST_ID: { + value: "POST_ID", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan + } + }) + }, + USER_ID: { + value: "USER_ID", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan2 + } + }) + }, + CREATED_AT: { + value: "CREATED_AT", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan3 + } + }) + }, + CREATED_AT_TRUNCATED_TO_HOUR: { + value: "CREATED_AT_TRUNCATED_TO_HOUR", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan4 + } + }) + }, + CREATED_AT_TRUNCATED_TO_DAY: { + value: "CREATED_AT_TRUNCATED_TO_DAY", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan5 + } + }) + }, + UPDATED_AT: { + value: "UPDATED_AT", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan6 + } + }) + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + value: "UPDATED_AT_TRUNCATED_TO_HOUR", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan7 + } + }) + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + value: "UPDATED_AT_TRUNCATED_TO_DAY", + extensions: Object.assign(Object.create(null), { + grafast: { + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan8 + } + }) + } + }) +}); +const relation4 = registry.pgRelations["project"]["postsByTheirProjectId"]; function OrganizationGroupBy_extensions_grafast_applyPlan($pgSelect) { $pgSelect.groupBy({ fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` @@ -3595,8 +4028,8 @@ export const OrganizationGroupBy = new GraphQLEnumType({ } }) }); -const relation4 = registry.pgRelations["organization"]["projectsByTheirOrganizationId"]; -const relation5 = registry.pgRelations["organization"]["userOrganizationsByTheirOrganizationId"]; +const relation5 = registry.pgRelations["organization"]["projectsByTheirOrganizationId"]; +const relation6 = registry.pgRelations["organization"]["userOrganizationsByTheirOrganizationId"]; function UserGroupBy_extensions_grafast_applyPlan($pgSelect) { $pgSelect.groupBy({ fragment: sql.fragment`${$pgSelect.alias}.${sql.identifier("created_at")}` @@ -3707,55 +4140,64 @@ export const UserGroupBy = new GraphQLEnumType({ } }) }); -const relation6 = registry.pgRelations["user"]["postsByTheirUserId"]; -const relation7 = registry.pgRelations["user"]["upvotesByTheirUserId"]; -const relation8 = registry.pgRelations["user"]["userOrganizationsByTheirUserId"]; -const relation9 = registry.pgRelations["user"]["commentsByTheirUserId"]; +const relation7 = registry.pgRelations["user"]["postsByTheirUserId"]; +const relation8 = registry.pgRelations["user"]["upvotesByTheirUserId"]; +const relation9 = registry.pgRelations["user"]["userOrganizationsByTheirUserId"]; +const relation10 = registry.pgRelations["user"]["commentsByTheirUserId"]; +const relation11 = registry.pgRelations["user"]["downvotesByTheirUserId"]; const specFromArgs = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Downvote, $nodeId); }; const specFromArgs2 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); }; const specFromArgs3 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); }; const specFromArgs4 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); }; const specFromArgs5 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); }; const specFromArgs6 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); }; const specFromArgs7 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); }; const specFromArgs8 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Downvote, $nodeId); }; const specFromArgs9 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Upvote, $nodeId); }; const specFromArgs10 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Organization, $nodeId); }; const specFromArgs11 = args => { const $nodeId = args.get(["input", "id"]); - return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); + return specFromNodeId(nodeIdHandlerByTypeName.Comment, $nodeId); }; const specFromArgs12 = args => { + const $nodeId = args.get(["input", "id"]); + return specFromNodeId(nodeIdHandlerByTypeName.Post, $nodeId); +}; +const specFromArgs13 = args => { + const $nodeId = args.get(["input", "id"]); + return specFromNodeId(nodeIdHandlerByTypeName.User, $nodeId); +}; +const specFromArgs14 = args => { const $nodeId = args.get(["input", "id"]); return specFromNodeId(nodeIdHandlerByTypeName.Project, $nodeId); }; @@ -3781,6 +4223,12 @@ type Query implements Node { """Get a single \`UserOrganization\`.""" userOrganizationByUserIdAndOrganizationId(userId: UUID!, organizationId: UUID!): UserOrganization + """Get a single \`Downvote\`.""" + downvote(rowId: UUID!): Downvote + + """Get a single \`Downvote\`.""" + downvoteByPostIdAndUserId(postId: UUID!, userId: UUID!): Downvote + """Get a single \`Upvote\`.""" upvote(rowId: UUID!): Upvote @@ -3820,6 +4268,12 @@ type Query implements Node { """Get a single \`Project\`.""" projectBySlugAndOrganizationId(slug: String!, organizationId: UUID!): Project + """Reads a single \`Downvote\` using its globally unique \`ID\`.""" + downvoteById( + """The globally unique \`ID\` to be used in selecting a single \`Downvote\`.""" + id: ID! + ): Downvote + """Reads a single \`Upvote\` using its globally unique \`ID\`.""" upvoteById( """The globally unique \`ID\` to be used in selecting a single \`Upvote\`.""" @@ -3892,6 +4346,40 @@ type Query implements Node { filter: UserOrganizationFilter ): UserOrganizationConnection + """Reads and enables pagination through a set of \`Downvote\`.""" + downvotes( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: DownvoteCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: DownvoteFilter + ): DownvoteConnection + """Reads and enables pagination through a set of \`Upvote\`.""" upvotes( """Only read the first \`n\` values of the set.""" @@ -4417,20 +4905,54 @@ type Post implements Node { """ filter: CommentFilter ): CommentConnection! -} -type User implements Node { - """ - A globally unique identifier. Can be used in various places throughout the system to identify this single value. - """ - id: ID! - rowId: UUID! - createdAt: Datetime - updatedAt: Datetime - hidraId: UUID! - username: String - firstName: String - lastName: String + """Reads and enables pagination through a set of \`Downvote\`.""" + downvotes( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: DownvoteCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: DownvoteFilter + ): DownvoteConnection! +} + +type User implements Node { + """ + A globally unique identifier. Can be used in various places throughout the system to identify this single value. + """ + id: ID! + rowId: UUID! + createdAt: Datetime + updatedAt: Datetime + hidraId: UUID! + username: String + firstName: String + lastName: String """Reads and enables pagination through a set of \`Post\`.""" posts( @@ -4567,6 +5089,40 @@ type User implements Node { """ filter: CommentFilter ): CommentConnection! + + """Reads and enables pagination through a set of \`Downvote\`.""" + downvotes( + """Only read the first \`n\` values of the set.""" + first: Int + + """Only read the last \`n\` values of the set.""" + last: Int + + """ + Skip the first \`n\` values from our \`after\` cursor, an alternative to cursor + based pagination. May not be used with \`last\`. + """ + offset: Int + + """Read all values in the set before (above) this cursor.""" + before: Cursor + + """Read all values in the set after (below) this cursor.""" + after: Cursor + + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!] = [PRIMARY_KEY_ASC] + + """ + A condition to be used in determining which values should be returned by the collection. + """ + condition: DownvoteCondition + + """ + A filter to be used in determining which values should be returned by the collection. + """ + filter: DownvoteFilter + ): DownvoteConnection! } """A location in a connection that can be used for resuming pagination.""" @@ -4617,6 +5173,18 @@ enum PostOrderBy { COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC + DOWNVOTES_COUNT_ASC + DOWNVOTES_COUNT_DESC + DOWNVOTES_DISTINCT_COUNT_ROW_ID_ASC + DOWNVOTES_DISTINCT_COUNT_ROW_ID_DESC + DOWNVOTES_DISTINCT_COUNT_POST_ID_ASC + DOWNVOTES_DISTINCT_COUNT_POST_ID_DESC + DOWNVOTES_DISTINCT_COUNT_USER_ID_ASC + DOWNVOTES_DISTINCT_COUNT_USER_ID_DESC + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_ASC + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_DESC + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_ASC + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_DESC } """ @@ -4682,6 +5250,12 @@ input PostFilter { """Some related \`comments\` exist.""" commentsExist: Boolean + """Filter by the object’s \`downvotes\` relation.""" + downvotes: PostToManyDownvoteFilter + + """Some related \`downvotes\` exist.""" + downvotesExist: Boolean + """Filter by the object’s \`project\` relation.""" project: ProjectFilter @@ -5021,6 +5595,12 @@ input UserFilter { """Some related \`comments\` exist.""" commentsExist: Boolean + """Filter by the object’s \`downvotes\` relation.""" + downvotes: UserToManyDownvoteFilter + + """Some related \`downvotes\` exist.""" + downvotesExist: Boolean + """Checks for all expressions in this list.""" and: [UserFilter!] @@ -5501,6 +6081,83 @@ input CommentDistinctCountAggregateFilter { updatedAt: BigIntFilter } +""" +A filter to be used against many \`Downvote\` object types. All fields are combined with a logical ‘and.’ +""" +input UserToManyDownvoteFilter { + """ + Every related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + every: DownvoteFilter + + """ + Some related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + some: DownvoteFilter + + """ + No related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + none: DownvoteFilter + + """Aggregates across related \`Downvote\` match the filter criteria.""" + aggregates: DownvoteAggregatesFilter +} + +""" +A filter to be used against \`Downvote\` object types. All fields are combined with a logical ‘and.’ +""" +input DownvoteFilter { + """Filter by the object’s \`rowId\` field.""" + rowId: UUIDFilter + + """Filter by the object’s \`postId\` field.""" + postId: UUIDFilter + + """Filter by the object’s \`userId\` field.""" + userId: UUIDFilter + + """Filter by the object’s \`createdAt\` field.""" + createdAt: DatetimeFilter + + """Filter by the object’s \`updatedAt\` field.""" + updatedAt: DatetimeFilter + + """Filter by the object’s \`post\` relation.""" + post: PostFilter + + """Filter by the object’s \`user\` relation.""" + user: UserFilter + + """Checks for all expressions in this list.""" + and: [DownvoteFilter!] + + """Checks for any expressions in this list.""" + or: [DownvoteFilter!] + + """Negates the expression.""" + not: DownvoteFilter +} + +"""A filter to be used against aggregates of \`Downvote\` object types.""" +input DownvoteAggregatesFilter { + """ + A filter that must pass for the relevant \`Downvote\` object to be included within the aggregate. + """ + filter: DownvoteFilter + + """Distinct count aggregate over matching \`Downvote\` objects.""" + distinctCount: DownvoteDistinctCountAggregateFilter +} + +input DownvoteDistinctCountAggregateFilter { + rowId: BigIntFilter + postId: BigIntFilter + userId: BigIntFilter + createdAt: BigIntFilter + updatedAt: BigIntFilter +} + """ A filter to be used against many \`Comment\` object types. All fields are combined with a logical ‘and.’ """ @@ -5524,6 +6181,29 @@ input PostToManyCommentFilter { aggregates: CommentAggregatesFilter } +""" +A filter to be used against many \`Downvote\` object types. All fields are combined with a logical ‘and.’ +""" +input PostToManyDownvoteFilter { + """ + Every related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + every: DownvoteFilter + + """ + Some related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + some: DownvoteFilter + + """ + No related \`Downvote\` matches the filter criteria. All fields are combined with a logical ‘and.’ + """ + none: DownvoteFilter + + """Aggregates across related \`Downvote\` match the filter criteria.""" + aggregates: DownvoteAggregatesFilter +} + """A connection to a list of \`Upvote\` values.""" type UpvoteConnection { """A list of \`Upvote\` objects.""" @@ -6100,36 +6780,81 @@ input CommentCondition { updatedAt: Datetime } -"""A \`Post\` edge in the connection.""" -type PostEdge { +"""A connection to a list of \`Downvote\` values.""" +type DownvoteConnection { + """A list of \`Downvote\` objects.""" + nodes: [Downvote]! + + """ + A list of edges which contains the \`Downvote\` and cursor to aid in pagination. + """ + edges: [DownvoteEdge]! + + """Information to aid in pagination.""" + pageInfo: PageInfo! + + """The count of *all* \`Downvote\` you could get from the connection.""" + totalCount: Int! + + """ + Aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + aggregates: DownvoteAggregates + + """ + Grouped aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + groupedAggregates( + """The method to use when grouping \`Downvote\` for these aggregates.""" + groupBy: [DownvoteGroupBy!]! + + """Conditions on the grouped aggregates.""" + having: DownvoteHavingInput + ): [DownvoteAggregates!] +} + +type Downvote implements Node { + """ + A globally unique identifier. Can be used in various places throughout the system to identify this single value. + """ + id: ID! + rowId: UUID! + postId: UUID! + userId: UUID! + createdAt: Datetime + updatedAt: Datetime + + """Reads a single \`Post\` that is related to this \`Downvote\`.""" + post: Post + + """Reads a single \`User\` that is related to this \`Downvote\`.""" + user: User +} + +"""A \`Downvote\` edge in the connection.""" +type DownvoteEdge { """A cursor for use in pagination.""" cursor: Cursor - """The \`Post\` at the end of the edge.""" - node: Post + """The \`Downvote\` at the end of the edge.""" + node: Downvote } -type PostAggregates { +type DownvoteAggregates { keys: [String] """ Distinct count aggregates across the matching connection (ignoring before/after/first/last/offset) """ - distinctCount: PostDistinctCountAggregates + distinctCount: DownvoteDistinctCountAggregates } -type PostDistinctCountAggregates { +type DownvoteDistinctCountAggregates { """Distinct count of rowId across the matching connection""" rowId: BigInt - """Distinct count of title across the matching connection""" - title: BigInt - - """Distinct count of description across the matching connection""" - description: BigInt - - """Distinct count of projectId across the matching connection""" - projectId: BigInt + """Distinct count of postId across the matching connection""" + postId: BigInt """Distinct count of userId across the matching connection""" userId: BigInt @@ -6141,11 +6866,9 @@ type PostDistinctCountAggregates { updatedAt: BigInt } -"""Grouping methods for \`Post\` for usage during aggregation.""" -enum PostGroupBy { - TITLE - DESCRIPTION - PROJECT_ID +"""Grouping methods for \`Downvote\` for usage during aggregation.""" +enum DownvoteGroupBy { + POST_ID USER_ID CREATED_AT CREATED_AT_TRUNCATED_TO_HOUR @@ -6155,87 +6878,240 @@ enum PostGroupBy { UPDATED_AT_TRUNCATED_TO_DAY } -"""Conditions for \`Post\` aggregates.""" -input PostHavingInput { - AND: [PostHavingInput!] - OR: [PostHavingInput!] - sum: PostHavingSumInput - distinctCount: PostHavingDistinctCountInput - min: PostHavingMinInput - max: PostHavingMaxInput - average: PostHavingAverageInput - stddevSample: PostHavingStddevSampleInput - stddevPopulation: PostHavingStddevPopulationInput - varianceSample: PostHavingVarianceSampleInput - variancePopulation: PostHavingVariancePopulationInput +"""Conditions for \`Downvote\` aggregates.""" +input DownvoteHavingInput { + AND: [DownvoteHavingInput!] + OR: [DownvoteHavingInput!] + sum: DownvoteHavingSumInput + distinctCount: DownvoteHavingDistinctCountInput + min: DownvoteHavingMinInput + max: DownvoteHavingMaxInput + average: DownvoteHavingAverageInput + stddevSample: DownvoteHavingStddevSampleInput + stddevPopulation: DownvoteHavingStddevPopulationInput + varianceSample: DownvoteHavingVarianceSampleInput + variancePopulation: DownvoteHavingVariancePopulationInput } -input PostHavingSumInput { +input DownvoteHavingSumInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingDistinctCountInput { +input DownvoteHavingDistinctCountInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingMinInput { +input DownvoteHavingMinInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingMaxInput { +input DownvoteHavingMaxInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingAverageInput { +input DownvoteHavingAverageInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingStddevSampleInput { +input DownvoteHavingStddevSampleInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingStddevPopulationInput { +input DownvoteHavingStddevPopulationInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingVarianceSampleInput { +input DownvoteHavingVarianceSampleInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -input PostHavingVariancePopulationInput { +input DownvoteHavingVariancePopulationInput { createdAt: HavingDatetimeFilter updatedAt: HavingDatetimeFilter } -"""A \`Project\` edge in the connection.""" -type ProjectEdge { - """A cursor for use in pagination.""" - cursor: Cursor - - """The \`Project\` at the end of the edge.""" - node: Project +"""Methods to use when ordering \`Downvote\`.""" +enum DownvoteOrderBy { + NATURAL + PRIMARY_KEY_ASC + PRIMARY_KEY_DESC + ROW_ID_ASC + ROW_ID_DESC + POST_ID_ASC + POST_ID_DESC + USER_ID_ASC + USER_ID_DESC + CREATED_AT_ASC + CREATED_AT_DESC + UPDATED_AT_ASC + UPDATED_AT_DESC } -type ProjectAggregates { - keys: [String] +""" +A condition to be used against \`Downvote\` object types. All fields are tested +for equality and combined with a logical ‘and.’ +""" +input DownvoteCondition { + """Checks for equality with the object’s \`rowId\` field.""" + rowId: UUID - """ - Distinct count aggregates across the matching connection (ignoring before/after/first/last/offset) - """ - distinctCount: ProjectDistinctCountAggregates -} + """Checks for equality with the object’s \`postId\` field.""" + postId: UUID -type ProjectDistinctCountAggregates { - """Distinct count of rowId across the matching connection""" - rowId: BigInt + """Checks for equality with the object’s \`userId\` field.""" + userId: UUID + + """Checks for equality with the object’s \`createdAt\` field.""" + createdAt: Datetime + + """Checks for equality with the object’s \`updatedAt\` field.""" + updatedAt: Datetime +} + +"""A \`Post\` edge in the connection.""" +type PostEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The \`Post\` at the end of the edge.""" + node: Post +} + +type PostAggregates { + keys: [String] + + """ + Distinct count aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + distinctCount: PostDistinctCountAggregates +} + +type PostDistinctCountAggregates { + """Distinct count of rowId across the matching connection""" + rowId: BigInt + + """Distinct count of title across the matching connection""" + title: BigInt + + """Distinct count of description across the matching connection""" + description: BigInt + + """Distinct count of projectId across the matching connection""" + projectId: BigInt + + """Distinct count of userId across the matching connection""" + userId: BigInt + + """Distinct count of createdAt across the matching connection""" + createdAt: BigInt + + """Distinct count of updatedAt across the matching connection""" + updatedAt: BigInt +} + +"""Grouping methods for \`Post\` for usage during aggregation.""" +enum PostGroupBy { + TITLE + DESCRIPTION + PROJECT_ID + USER_ID + CREATED_AT + CREATED_AT_TRUNCATED_TO_HOUR + CREATED_AT_TRUNCATED_TO_DAY + UPDATED_AT + UPDATED_AT_TRUNCATED_TO_HOUR + UPDATED_AT_TRUNCATED_TO_DAY +} + +"""Conditions for \`Post\` aggregates.""" +input PostHavingInput { + AND: [PostHavingInput!] + OR: [PostHavingInput!] + sum: PostHavingSumInput + distinctCount: PostHavingDistinctCountInput + min: PostHavingMinInput + max: PostHavingMaxInput + average: PostHavingAverageInput + stddevSample: PostHavingStddevSampleInput + stddevPopulation: PostHavingStddevPopulationInput + varianceSample: PostHavingVarianceSampleInput + variancePopulation: PostHavingVariancePopulationInput +} + +input PostHavingSumInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingDistinctCountInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingMinInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingMaxInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingAverageInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingStddevSampleInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingStddevPopulationInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingVarianceSampleInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +input PostHavingVariancePopulationInput { + createdAt: HavingDatetimeFilter + updatedAt: HavingDatetimeFilter +} + +"""A \`Project\` edge in the connection.""" +type ProjectEdge { + """A cursor for use in pagination.""" + cursor: Cursor + + """The \`Project\` at the end of the edge.""" + node: Project +} + +type ProjectAggregates { + keys: [String] + + """ + Distinct count aggregates across the matching connection (ignoring before/after/first/last/offset) + """ + distinctCount: ProjectDistinctCountAggregates +} + +type ProjectDistinctCountAggregates { + """Distinct count of rowId across the matching connection""" + rowId: BigInt """Distinct count of name across the matching connection""" name: BigInt @@ -6818,6 +7694,18 @@ enum UserOrderBy { COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC + DOWNVOTES_COUNT_ASC + DOWNVOTES_COUNT_DESC + DOWNVOTES_DISTINCT_COUNT_ROW_ID_ASC + DOWNVOTES_DISTINCT_COUNT_ROW_ID_DESC + DOWNVOTES_DISTINCT_COUNT_POST_ID_ASC + DOWNVOTES_DISTINCT_COUNT_POST_ID_DESC + DOWNVOTES_DISTINCT_COUNT_USER_ID_ASC + DOWNVOTES_DISTINCT_COUNT_USER_ID_DESC + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_ASC + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_DESC + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_ASC + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_DESC } """ @@ -6858,6 +7746,14 @@ type Mutation { input: CreateUserOrganizationInput! ): CreateUserOrganizationPayload + """Creates a single \`Downvote\`.""" + createDownvote( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: CreateDownvoteInput! + ): CreateDownvotePayload + """Creates a single \`Upvote\`.""" createUpvote( """ @@ -6914,6 +7810,30 @@ type Mutation { input: UpdateUserOrganizationByUserIdAndOrganizationIdInput! ): UpdateUserOrganizationPayload + """Updates a single \`Downvote\` using its globally unique id and a patch.""" + updateDownvoteById( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: UpdateDownvoteByIdInput! + ): UpdateDownvotePayload + + """Updates a single \`Downvote\` using a unique key and a patch.""" + updateDownvote( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: UpdateDownvoteInput! + ): UpdateDownvotePayload + + """Updates a single \`Downvote\` using a unique key and a patch.""" + updateDownvoteByPostIdAndUserId( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: UpdateDownvoteByPostIdAndUserIdInput! + ): UpdateDownvotePayload + """Updates a single \`Upvote\` using its globally unique id and a patch.""" updateUpvoteById( """ @@ -7076,6 +7996,30 @@ type Mutation { input: DeleteUserOrganizationByUserIdAndOrganizationIdInput! ): DeleteUserOrganizationPayload + """Deletes a single \`Downvote\` using its globally unique id.""" + deleteDownvoteById( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: DeleteDownvoteByIdInput! + ): DeleteDownvotePayload + + """Deletes a single \`Downvote\` using a unique key.""" + deleteDownvote( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: DeleteDownvoteInput! + ): DeleteDownvotePayload + + """Deletes a single \`Downvote\` using a unique key.""" + deleteDownvoteByPostIdAndUserId( + """ + The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. + """ + input: DeleteDownvoteByPostIdAndUserIdInput! + ): DeleteDownvotePayload + """Deletes a single \`Upvote\` using its globally unique id.""" deleteUpvoteById( """ @@ -7265,6 +8209,50 @@ input UserOrganizationInput { createdAt: Datetime } +"""The output of our create \`Downvote\` mutation.""" +type CreateDownvotePayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Downvote\` that was created by this mutation.""" + downvote: Downvote + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Downvote\`. May be used by Relay 1.""" + downvoteEdge( + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!]! = [PRIMARY_KEY_ASC] + ): DownvoteEdge +} + +"""All input for the create \`Downvote\` mutation.""" +input CreateDownvoteInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """The \`Downvote\` to be created by this mutation.""" + downvote: DownvoteInput! +} + +"""An input for mutations affecting \`Downvote\`""" +input DownvoteInput { + rowId: UUID + postId: UUID! + userId: UUID! + createdAt: Datetime + updatedAt: Datetime +} + """The output of our create \`Upvote\` mutation.""" type CreateUpvotePayload { """ @@ -7581,31 +8569,31 @@ input UserOrganizationPatch { createdAt: Datetime } -"""The output of our update \`Upvote\` mutation.""" -type UpdateUpvotePayload { +"""The output of our update \`Downvote\` mutation.""" +type UpdateDownvotePayload { """ The exact same \`clientMutationId\` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations. """ clientMutationId: String - """The \`Upvote\` that was updated by this mutation.""" - upvote: Upvote + """The \`Downvote\` that was updated by this mutation.""" + downvote: Downvote """ Our root query field type. Allows us to run any query from our mutation payload. """ query: Query - """An edge for our \`Upvote\`. May be used by Relay 1.""" - upvoteEdge( - """The method to use when ordering \`Upvote\`.""" - orderBy: [UpvoteOrderBy!]! = [PRIMARY_KEY_ASC] - ): UpvoteEdge + """An edge for our \`Downvote\`. May be used by Relay 1.""" + downvoteEdge( + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!]! = [PRIMARY_KEY_ASC] + ): DownvoteEdge } -"""All input for the \`updateUpvoteById\` mutation.""" -input UpdateUpvoteByIdInput { +"""All input for the \`updateDownvoteById\` mutation.""" +input UpdateDownvoteByIdInput { """ An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client. @@ -7613,20 +8601,20 @@ input UpdateUpvoteByIdInput { clientMutationId: String """ - The globally unique \`ID\` which will identify a single \`Upvote\` to be updated. + The globally unique \`ID\` which will identify a single \`Downvote\` to be updated. """ id: ID! """ - An object where the defined keys will be set on the \`Upvote\` being updated. + An object where the defined keys will be set on the \`Downvote\` being updated. """ - patch: UpvotePatch! + patch: DownvotePatch! } """ -Represents an update to a \`Upvote\`. Fields that are set will be updated. +Represents an update to a \`Downvote\`. Fields that are set will be updated. """ -input UpvotePatch { +input DownvotePatch { rowId: UUID postId: UUID userId: UUID @@ -7634,8 +8622,8 @@ input UpvotePatch { updatedAt: Datetime } -"""All input for the \`updateUpvote\` mutation.""" -input UpdateUpvoteInput { +"""All input for the \`updateDownvote\` mutation.""" +input UpdateDownvoteInput { """ An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client. @@ -7644,13 +8632,13 @@ input UpdateUpvoteInput { rowId: UUID! """ - An object where the defined keys will be set on the \`Upvote\` being updated. + An object where the defined keys will be set on the \`Downvote\` being updated. """ - patch: UpvotePatch! + patch: DownvotePatch! } -"""All input for the \`updateUpvoteByPostIdAndUserId\` mutation.""" -input UpdateUpvoteByPostIdAndUserIdInput { +"""All input for the \`updateDownvoteByPostIdAndUserId\` mutation.""" +input UpdateDownvoteByPostIdAndUserIdInput { """ An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client. @@ -7660,36 +8648,36 @@ input UpdateUpvoteByPostIdAndUserIdInput { userId: UUID! """ - An object where the defined keys will be set on the \`Upvote\` being updated. + An object where the defined keys will be set on the \`Downvote\` being updated. """ - patch: UpvotePatch! + patch: DownvotePatch! } -"""The output of our update \`Organization\` mutation.""" -type UpdateOrganizationPayload { +"""The output of our update \`Upvote\` mutation.""" +type UpdateUpvotePayload { """ The exact same \`clientMutationId\` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations. """ clientMutationId: String - """The \`Organization\` that was updated by this mutation.""" - organization: Organization + """The \`Upvote\` that was updated by this mutation.""" + upvote: Upvote """ Our root query field type. Allows us to run any query from our mutation payload. """ query: Query - """An edge for our \`Organization\`. May be used by Relay 1.""" - organizationEdge( - """The method to use when ordering \`Organization\`.""" - orderBy: [OrganizationOrderBy!]! = [PRIMARY_KEY_ASC] - ): OrganizationEdge + """An edge for our \`Upvote\`. May be used by Relay 1.""" + upvoteEdge( + """The method to use when ordering \`Upvote\`.""" + orderBy: [UpvoteOrderBy!]! = [PRIMARY_KEY_ASC] + ): UpvoteEdge } -"""All input for the \`updateOrganizationById\` mutation.""" -input UpdateOrganizationByIdInput { +"""All input for the \`updateUpvoteById\` mutation.""" +input UpdateUpvoteByIdInput { """ An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client. @@ -7697,18 +8685,102 @@ input UpdateOrganizationByIdInput { clientMutationId: String """ - The globally unique \`ID\` which will identify a single \`Organization\` to be updated. + The globally unique \`ID\` which will identify a single \`Upvote\` to be updated. """ id: ID! """ - An object where the defined keys will be set on the \`Organization\` being updated. + An object where the defined keys will be set on the \`Upvote\` being updated. """ - patch: OrganizationPatch! + patch: UpvotePatch! } """ -Represents an update to a \`Organization\`. Fields that are set will be updated. +Represents an update to a \`Upvote\`. Fields that are set will be updated. +""" +input UpvotePatch { + rowId: UUID + postId: UUID + userId: UUID + createdAt: Datetime + updatedAt: Datetime +} + +"""All input for the \`updateUpvote\` mutation.""" +input UpdateUpvoteInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + rowId: UUID! + + """ + An object where the defined keys will be set on the \`Upvote\` being updated. + """ + patch: UpvotePatch! +} + +"""All input for the \`updateUpvoteByPostIdAndUserId\` mutation.""" +input UpdateUpvoteByPostIdAndUserIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + postId: UUID! + userId: UUID! + + """ + An object where the defined keys will be set on the \`Upvote\` being updated. + """ + patch: UpvotePatch! +} + +"""The output of our update \`Organization\` mutation.""" +type UpdateOrganizationPayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Organization\` that was updated by this mutation.""" + organization: Organization + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Organization\`. May be used by Relay 1.""" + organizationEdge( + """The method to use when ordering \`Organization\`.""" + orderBy: [OrganizationOrderBy!]! = [PRIMARY_KEY_ASC] + ): OrganizationEdge +} + +"""All input for the \`updateOrganizationById\` mutation.""" +input UpdateOrganizationByIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """ + The globally unique \`ID\` which will identify a single \`Organization\` to be updated. + """ + id: ID! + + """ + An object where the defined keys will be set on the \`Organization\` being updated. + """ + patch: OrganizationPatch! +} + +""" +Represents an update to a \`Organization\`. Fields that are set will be updated. """ input OrganizationPatch { rowId: UUID @@ -8130,6 +9202,65 @@ input DeleteUserOrganizationByUserIdAndOrganizationIdInput { organizationId: UUID! } +"""The output of our delete \`Downvote\` mutation.""" +type DeleteDownvotePayload { + """ + The exact same \`clientMutationId\` that was provided in the mutation input, + unchanged and unused. May be used by a client to track mutations. + """ + clientMutationId: String + + """The \`Downvote\` that was deleted by this mutation.""" + downvote: Downvote + deletedDownvoteId: ID + + """ + Our root query field type. Allows us to run any query from our mutation payload. + """ + query: Query + + """An edge for our \`Downvote\`. May be used by Relay 1.""" + downvoteEdge( + """The method to use when ordering \`Downvote\`.""" + orderBy: [DownvoteOrderBy!]! = [PRIMARY_KEY_ASC] + ): DownvoteEdge +} + +"""All input for the \`deleteDownvoteById\` mutation.""" +input DeleteDownvoteByIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + + """ + The globally unique \`ID\` which will identify a single \`Downvote\` to be deleted. + """ + id: ID! +} + +"""All input for the \`deleteDownvote\` mutation.""" +input DeleteDownvoteInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + rowId: UUID! +} + +"""All input for the \`deleteDownvoteByPostIdAndUserId\` mutation.""" +input DeleteDownvoteByPostIdAndUserIdInput { + """ + An arbitrary string value with no semantic meaning. Will be included in the + payload verbatim. May be used to track mutations by the client. + """ + clientMutationId: String + postId: UUID! + userId: UUID! +} + """The output of our delete \`Upvote\` mutation.""" type DeleteUpvotePayload { """ @@ -8521,6 +9652,28 @@ export const plans = { organizationId: undefined } }, + downvote: { + plan(_$root, args) { + return pgResource_downvotePgResource.get({ + id: args.get("rowId") + }); + }, + args: { + rowId: undefined + } + }, + downvoteByPostIdAndUserId: { + plan(_$root, args) { + return pgResource_downvotePgResource.get({ + post_id: args.get("postId"), + user_id: args.get("userId") + }); + }, + args: { + postId: undefined, + userId: undefined + } + }, upvote: { plan(_$root, args) { return pgResource_upvotePgResource.get({ @@ -8655,7 +9808,7 @@ export const plans = { organizationId: undefined } }, - upvoteById: { + downvoteById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher($nodeId); @@ -8664,7 +9817,7 @@ export const plans = { id: undefined } }, - organizationById: { + upvoteById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher2($nodeId); @@ -8673,7 +9826,7 @@ export const plans = { id: undefined } }, - commentById: { + organizationById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher3($nodeId); @@ -8682,7 +9835,7 @@ export const plans = { id: undefined } }, - postById: { + commentById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher4($nodeId); @@ -8691,7 +9844,7 @@ export const plans = { id: undefined } }, - userById: { + postById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher5($nodeId); @@ -8700,7 +9853,7 @@ export const plans = { id: undefined } }, - projectById: { + userById: { plan(_$parent, args) { const $nodeId = args.get("id"); return fetcher6($nodeId); @@ -8709,6 +9862,15 @@ export const plans = { id: undefined } }, + projectById: { + plan(_$parent, args) { + const $nodeId = args.get("id"); + return fetcher7($nodeId); + }, + args: { + id: undefined + } + }, userOrganizations: { plan() { return connection(resource_user_organizationPgResource.find()); @@ -8772,6 +9934,69 @@ export const plans = { } } }, + downvotes: { + plan() { + return connection(pgResource_downvotePgResource.find()); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed2(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + }, upvotes: { plan() { return connection(pgResource_upvotePgResource.find()); @@ -8825,7 +10050,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed2(fieldArgs, "object"); + assertAllowed3(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8888,7 +10113,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed3(fieldArgs, "object"); + assertAllowed4(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -8951,7 +10176,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed4(fieldArgs, "object"); + assertAllowed5(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9014,7 +10239,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed5(fieldArgs, "object"); + assertAllowed6(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9077,7 +10302,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed6(fieldArgs, "object"); + assertAllowed7(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9140,7 +10365,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed7(fieldArgs, "object"); + assertAllowed8(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9268,7 +10493,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed8(fieldArgs, "object"); + assertAllowed9(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9334,7 +10559,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed9(fieldArgs, "object"); + assertAllowed10(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9481,7 +10706,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed10(fieldArgs, "object"); + assertAllowed11(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9630,7 +10855,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed11(fieldArgs, "object"); + assertAllowed12(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9696,7 +10921,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed12(fieldArgs, "object"); + assertAllowed13(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9705,16 +10930,82 @@ export const plans = { } } } - } - }, - User: { - __assertStep: assertPgClassSingleStep, - id($parent) { - const specifier = nodeIdHandlerByTypeName.User.plan($parent); - return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.User.codec.name].encode); - }, - rowId($record) { - return $record.get("id"); + }, + downvotes: { + plan($record) { + const $records = pgResource_downvotePgResource.find({ + post_id: $record.get("id") + }); + return connection($records); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed14(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + } + }, + User: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.User.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.User.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); }, createdAt($record) { return $record.get("created_at"); @@ -9790,7 +11081,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed13(fieldArgs, "object"); + assertAllowed15(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9856,7 +11147,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed14(fieldArgs, "object"); + assertAllowed16(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9922,7 +11213,7 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed15(fieldArgs, "object"); + assertAllowed17(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -9988,7 +11279,73 @@ export const plans = { filter: { autoApplyAfterParentPlan: true, applyPlan(_, $connection, fieldArgs) { - assertAllowed16(fieldArgs, "object"); + assertAllowed18(fieldArgs, "object"); + const $where = $connection.getSubplan().wherePlan(); + if (null) $where.extensions.pgFilterAttribute = { + codec: null + }; + fieldArgs.apply($where); + } + } + } + }, + downvotes: { + plan($record) { + const $records = pgResource_downvotePgResource.find({ + user_id: $record.get("id") + }); + return connection($records); + }, + args: { + first: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, arg) { + $connection.setFirst(arg.getRaw()); + } + }, + last: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setLast(val.getRaw()); + } + }, + offset: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setOffset(val.getRaw()); + } + }, + before: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setBefore(val.getRaw()); + } + }, + after: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val) { + $connection.setAfter(val.getRaw()); + } + }, + orderBy: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, val, info) { + const $value = val.getRaw(), + $select = $connection.getSubplan(); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + return null; + } + }, + condition: { + autoApplyAfterParentPlan: true, + applyPlan(_condition, $connection) { + return $connection.getSubplan().wherePlan(); + } + }, + filter: { + autoApplyAfterParentPlan: true, + applyPlan(_, $connection, fieldArgs) { + assertAllowed19(fieldArgs, "object"); const $where = $connection.getSubplan().wherePlan(); if (null) $where.extensions.pgFilterAttribute = { codec: null @@ -10788,86 +12145,346 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; direction: "DESC" }); } - } - }, - PostCondition: { - rowId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true }, - title: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "title", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "title", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.title.codec)}`; - } + DOWNVOTES_COUNT_ASC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "ASC" + }); + } }, - description: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "description", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "description", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.description.codec)}`; - } + DOWNVOTES_COUNT_DESC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "DESC" + }); + } }, - projectId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "project_id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "project_id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.project_id.codec)}`; - } + DOWNVOTES_DISTINCT_COUNT_ROW_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_downvote.attributes.id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.id.codec, + direction: "ASC" + }); + } }, - userId: { + DOWNVOTES_DISTINCT_COUNT_ROW_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_downvote.attributes.id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.id.codec, + direction: "DESC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_POST_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_downvote.attributes.post_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.post_id.codec, + direction: "ASC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_POST_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_downvote.attributes.post_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.post_id.codec, + direction: "DESC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_USER_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_downvote.attributes.user_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.user_id.codec, + direction: "ASC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_USER_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_downvote.attributes.user_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.user_id.codec, + direction: "DESC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_downvote.attributes.created_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.created_at.codec, + direction: "ASC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_downvote.attributes.created_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.created_at.codec, + direction: "DESC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_downvote.attributes.updated_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.updated_at.codec, + direction: "ASC" + }); + } + }, + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation3.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation3.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_downvote.attributes.updated_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.updated_at.codec, + direction: "DESC" + }); + } + } + }, + PostCondition: { + rowId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + title: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "title", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "title", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.title.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + description: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "description", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "description", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.description.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + projectId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "project_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "project_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_post.attributes.project_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", @@ -11005,7 +12622,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotes: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "object"); + assertAllowed20(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: upvoteIdentifier, @@ -11018,7 +12635,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotesExist: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "scalar"); + assertAllowed20(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: upvoteIdentifier, alias: pgResource_upvotePgResource.name, @@ -11032,7 +12649,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, comments: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "object"); + assertAllowed20(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: commentIdentifier, @@ -11045,7 +12662,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, commentsExist: { applyPlan($where, fieldArgs) { - assertAllowed17(fieldArgs, "scalar"); + assertAllowed20(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: commentIdentifier, alias: pgResource_commentPgResource.name, @@ -11057,9 +12674,36 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); } }, + downvotes: { + applyPlan($where, fieldArgs) { + assertAllowed20(fieldArgs, "object"); + const $rel = $where.andPlan(); + $rel.extensions.pgFilterRelation = { + tableExpression: downvoteIdentifier, + alias: pgResource_downvotePgResource.name, + localAttributes: registryConfig.pgRelations.post.downvotesByTheirPostId.localAttributes, + remoteAttributes: registryConfig.pgRelations.post.downvotesByTheirPostId.remoteAttributes + }; + fieldArgs.apply($rel); + } + }, + downvotesExist: { + applyPlan($where, fieldArgs) { + assertAllowed20(fieldArgs, "scalar"); + const $subQuery = $where.existsPlan({ + tableExpression: downvoteIdentifier, + alias: pgResource_downvotePgResource.name, + $equals: fieldArgs.get() + }); + registryConfig.pgRelations.post.downvotesByTheirPostId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.post.downvotesByTheirPostId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + } + }, project: { applyPlan($where, fieldArgs) { - assertAllowed18(fieldArgs, "object"); + assertAllowed21(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: projectIdentifier, alias: pgResource_projectPgResource.name @@ -11073,7 +12717,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed18(fieldArgs, "object"); + assertAllowed21(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -11087,21 +12731,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "list"); + assertAllowed22(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "list"); + assertAllowed22(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed19(fieldArgs, "object"); + assertAllowed22(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -12709,7 +14353,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; PostToManyUpvoteFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12730,7 +14374,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12751,7 +14395,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed20(fieldArgs, "object"); + assertAllowed23(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -12850,7 +14494,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, post: { applyPlan($where, fieldArgs) { - assertAllowed21(fieldArgs, "object"); + assertAllowed24(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name @@ -12864,7 +14508,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed21(fieldArgs, "object"); + assertAllowed24(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -12878,21 +14522,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "list"); + assertAllowed25(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "list"); + assertAllowed25(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed22(fieldArgs, "object"); + assertAllowed25(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -12978,7 +14622,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, posts: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: postIdentifier, @@ -12991,7 +14635,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, postsExist: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "scalar"); + assertAllowed26(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name, @@ -13005,7 +14649,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotes: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: upvoteIdentifier, @@ -13018,7 +14662,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, upvotesExist: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "scalar"); + assertAllowed26(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: upvoteIdentifier, alias: pgResource_upvotePgResource.name, @@ -13032,7 +14676,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizations: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: userOrganizationIdentifier, @@ -13045,7 +14689,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizationsExist: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "scalar"); + assertAllowed26(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: userOrganizationIdentifier, alias: resource_user_organizationPgResource.name, @@ -13059,7 +14703,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, comments: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "object"); + assertAllowed26(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: commentIdentifier, @@ -13072,7 +14716,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, commentsExist: { applyPlan($where, fieldArgs) { - assertAllowed23(fieldArgs, "scalar"); + assertAllowed26(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: commentIdentifier, alias: pgResource_commentPgResource.name, @@ -13084,23 +14728,50 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); } }, + downvotes: { + applyPlan($where, fieldArgs) { + assertAllowed26(fieldArgs, "object"); + const $rel = $where.andPlan(); + $rel.extensions.pgFilterRelation = { + tableExpression: downvoteIdentifier, + alias: pgResource_downvotePgResource.name, + localAttributes: registryConfig.pgRelations.user.downvotesByTheirUserId.localAttributes, + remoteAttributes: registryConfig.pgRelations.user.downvotesByTheirUserId.remoteAttributes + }; + fieldArgs.apply($rel); + } + }, + downvotesExist: { + applyPlan($where, fieldArgs) { + assertAllowed26(fieldArgs, "scalar"); + const $subQuery = $where.existsPlan({ + tableExpression: downvoteIdentifier, + alias: pgResource_downvotePgResource.name, + $equals: fieldArgs.get() + }); + registryConfig.pgRelations.user.downvotesByTheirUserId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.user.downvotesByTheirUserId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + } + }, and: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "list"); + assertAllowed27(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "list"); + assertAllowed27(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed24(fieldArgs, "object"); + assertAllowed27(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -13109,7 +14780,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyPostFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed25(fieldArgs, "object"); + assertAllowed28(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13130,7 +14801,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed25(fieldArgs, "object"); + assertAllowed28(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13151,7 +14822,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed25(fieldArgs, "object"); + assertAllowed28(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13587,7 +15258,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyUpvoteFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "object"); + assertAllowed29(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13608,7 +15279,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "object"); + assertAllowed29(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13629,7 +15300,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed26(fieldArgs, "object"); + assertAllowed29(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13738,7 +15409,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyUserOrganizationFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "object"); + assertAllowed30(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13759,7 +15430,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "object"); + assertAllowed30(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13780,7 +15451,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed27(fieldArgs, "object"); + assertAllowed30(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -13857,7 +15528,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, organization: { applyPlan($where, fieldArgs) { - assertAllowed28(fieldArgs, "object"); + assertAllowed31(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: organizationIdentifier, alias: pgResource_organizationPgResource.name @@ -13871,7 +15542,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed28(fieldArgs, "object"); + assertAllowed31(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -13885,21 +15556,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "list"); + assertAllowed32(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "list"); + assertAllowed32(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed29(fieldArgs, "object"); + assertAllowed32(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -13963,7 +15634,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, projects: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "object"); + assertAllowed33(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: projectIdentifier, @@ -13976,7 +15647,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, projectsExist: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "scalar"); + assertAllowed33(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: projectIdentifier, alias: pgResource_projectPgResource.name, @@ -13990,7 +15661,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizations: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "object"); + assertAllowed33(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: userOrganizationIdentifier, @@ -14003,7 +15674,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, userOrganizationsExist: { applyPlan($where, fieldArgs) { - assertAllowed30(fieldArgs, "scalar"); + assertAllowed33(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: userOrganizationIdentifier, alias: resource_user_organizationPgResource.name, @@ -14017,21 +15688,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed31(fieldArgs, "list"); + assertAllowed34(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed31(fieldArgs, "list"); + assertAllowed34(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed31(fieldArgs, "object"); + assertAllowed34(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -14040,7 +15711,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; OrganizationToManyProjectFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "object"); + assertAllowed35(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14061,7 +15732,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "object"); + assertAllowed35(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14082,7 +15753,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed32(fieldArgs, "object"); + assertAllowed35(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14214,7 +15885,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, posts: { applyPlan($where, fieldArgs) { - assertAllowed33(fieldArgs, "object"); + assertAllowed36(fieldArgs, "object"); const $rel = $where.andPlan(); $rel.extensions.pgFilterRelation = { tableExpression: postIdentifier, @@ -14227,7 +15898,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, postsExist: { applyPlan($where, fieldArgs) { - assertAllowed33(fieldArgs, "scalar"); + assertAllowed36(fieldArgs, "scalar"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name, @@ -14241,7 +15912,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, organization: { applyPlan($where, fieldArgs) { - assertAllowed34(fieldArgs, "object"); + assertAllowed37(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: organizationIdentifier, alias: pgResource_organizationPgResource.name @@ -14255,21 +15926,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed35(fieldArgs, "list"); + assertAllowed38(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed35(fieldArgs, "list"); + assertAllowed38(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed35(fieldArgs, "object"); + assertAllowed38(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -14278,7 +15949,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; ProjectToManyPostFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed36(fieldArgs, "object"); + assertAllowed39(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14299,7 +15970,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed36(fieldArgs, "object"); + assertAllowed39(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14320,7 +15991,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed36(fieldArgs, "object"); + assertAllowed39(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14459,7 +16130,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; OrganizationToManyUserOrganizationFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed37(fieldArgs, "object"); + assertAllowed40(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14480,7 +16151,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed37(fieldArgs, "object"); + assertAllowed40(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14501,7 +16172,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed37(fieldArgs, "object"); + assertAllowed40(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14590,7 +16261,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; UserToManyCommentFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed38(fieldArgs, "object"); + assertAllowed41(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14611,7 +16282,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed38(fieldArgs, "object"); + assertAllowed41(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14632,7 +16303,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed38(fieldArgs, "object"); + assertAllowed41(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14742,7 +16413,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, post: { applyPlan($where, fieldArgs) { - assertAllowed39(fieldArgs, "object"); + assertAllowed42(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: postIdentifier, alias: pgResource_postPgResource.name @@ -14756,7 +16427,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, user: { applyPlan($where, fieldArgs) { - assertAllowed39(fieldArgs, "object"); + assertAllowed42(fieldArgs, "object"); const $subQuery = $where.existsPlan({ tableExpression: userIdentifier, alias: pgResource_userPgResource.name @@ -14770,21 +16441,21 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, and: { applyPlan($where, fieldArgs) { - assertAllowed40(fieldArgs, "list"); + assertAllowed43(fieldArgs, "list"); const $and = $where.andPlan(); fieldArgs.apply($and); } }, or: { applyPlan($where, fieldArgs) { - assertAllowed40(fieldArgs, "list"); + assertAllowed43(fieldArgs, "list"); const $or = $where.orPlan(); fieldArgs.apply(() => $or.andPlan()); } }, not: { applyPlan($where, fieldArgs) { - assertAllowed40(fieldArgs, "object"); + assertAllowed43(fieldArgs, "object"); const $and = $where.notPlan().andPlan(); fieldArgs.apply($and); } @@ -14865,10 +16536,10 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - PostToManyCommentFilter: { + UserToManyDownvoteFilter: { every: { applyPlan($where, fieldArgs) { - assertAllowed41(fieldArgs, "object"); + assertAllowed44(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14889,7 +16560,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, some: { applyPlan($where, fieldArgs) { - assertAllowed41(fieldArgs, "object"); + assertAllowed44(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14910,7 +16581,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, none: { applyPlan($where, fieldArgs) { - assertAllowed41(fieldArgs, "object"); + assertAllowed44(fieldArgs, "object"); if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); const { localAttributes, @@ -14951,108 +16622,1074 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UpvoteConnection: { - __assertStep: ConnectionStep, - nodes($connection) { - return $connection.nodes(); - }, - edges($connection) { - return $connection.edges(); - }, - pageInfo($connection) { - return $connection.pageInfo(); - }, - totalCount($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + DownvoteFilter: { + rowId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec42; + fieldArgs.apply($col); + } }, - aggregates($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate").single(); + postId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec43; + fieldArgs.apply($col); + } }, - groupedAggregates: { - plan($connection) { - return $connection.cloneSubplanWithoutPagination("aggregate"); - }, - args: { - groupBy: { - autoApplyAfterParentPlan: true, - applyPlan(_$parent, $pgSelect, input) { - var _a, _b; - const val = input.getRaw().eval(); - if (!Array.isArray(val)) throw new Error("Invalid!"); - for (const group of val) { - const config = getEnumValueConfig(UpvoteGroupBy, group), - plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; - if (typeof plan === "function") plan($pgSelect); - } - return null; - } - }, - having: { - autoApplyAfterParentPlan: true, - applyPlan(_$parent, $pgSelect) { - return $pgSelect.havingPlan(); - } - } + userId: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec44; + fieldArgs.apply($col); } - } - }, - Upvote: { - __assertStep: assertPgClassSingleStep, - id($parent) { - const specifier = nodeIdHandlerByTypeName.Upvote.plan($parent); - return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Upvote.codec.name].encode); }, - rowId($record) { - return $record.get("id"); + createdAt: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec45; + fieldArgs.apply($col); + } }, - postId($record) { - return $record.get("post_id"); + updatedAt: { + applyPlan($where, fieldArgs) { + const $raw = fieldArgs.getRaw(); + if ($raw.evalIs(void 0)) return; + if (!false && "evalIsEmpty" in $raw && $raw.evalIsEmpty()) throw Object.assign(new Error("Empty objects are forbidden in filter argument input."), {}); + if (!false && $raw.evalIs(null)) throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {}); + const $col = new PgConditionStep($where); + $col.extensions.pgFilterAttribute = colSpec46; + fieldArgs.apply($col); + } }, - userId($record) { - return $record.get("user_id"); + post: { + applyPlan($where, fieldArgs) { + assertAllowed45(fieldArgs, "object"); + const $subQuery = $where.existsPlan({ + tableExpression: postIdentifier, + alias: pgResource_postPgResource.name + }); + registryConfig.pgRelations.downvote.postByMyPostId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.downvote.postByMyPostId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } }, - createdAt($record) { - return $record.get("created_at"); + user: { + applyPlan($where, fieldArgs) { + assertAllowed45(fieldArgs, "object"); + const $subQuery = $where.existsPlan({ + tableExpression: userIdentifier, + alias: pgResource_userPgResource.name + }); + registryConfig.pgRelations.downvote.userByMyUserId.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = registryConfig.pgRelations.downvote.userByMyUserId.remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } }, - updatedAt($record) { - return $record.get("updated_at"); + and: { + applyPlan($where, fieldArgs) { + assertAllowed46(fieldArgs, "list"); + const $and = $where.andPlan(); + fieldArgs.apply($and); + } }, - post($record) { - return pgResource_postPgResource.get({ - id: $record.get("post_id") - }); + or: { + applyPlan($where, fieldArgs) { + assertAllowed46(fieldArgs, "list"); + const $or = $where.orPlan(); + fieldArgs.apply(() => $or.andPlan()); + } }, - user($record) { - return pgResource_userPgResource.get({ - id: $record.get("user_id") - }); + not: { + applyPlan($where, fieldArgs) { + assertAllowed46(fieldArgs, "object"); + const $and = $where.notPlan().andPlan(); + fieldArgs.apply($and); + } } }, - UpvoteEdge: { - __assertStep: assertEdgeCapableStep, - cursor($edge) { - return $edge.cursor(); + DownvoteAggregatesFilter: { + filter: { + applyPlan($subquery, fieldArgs) { + const $condition = new PgConditionStep($subquery, !1, "AND"); + fieldArgs.apply($condition); + } }, - node($edge) { - return $edge.node(); - } + distinctCount: { + applyPlan($subquery, fieldArgs) { + fieldArgs.apply($subquery.forAggregate(aggregateSpec)); + } + } + }, + DownvoteDistinctCountAggregateFilter: { + rowId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("id")}`, spec_downvote.attributes.id.codec) + }; + fieldArgs.apply($col); + } + }, + postId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("post_id")}`, spec_downvote.attributes.post_id.codec) + }; + fieldArgs.apply($col); + } + }, + userId: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("user_id")}`, spec_downvote.attributes.user_id.codec) + }; + fieldArgs.apply($col); + } + }, + createdAt: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("created_at")}`, spec_downvote.attributes.created_at.codec) + }; + fieldArgs.apply($col); + } + }, + updatedAt: { + applyPlan($parent, fieldArgs) { + const $col = new PgConditionStep($parent); + $col.extensions.pgFilterAttribute = { + codec: TYPES.bigint, + expression: aggregateSpec.sqlAggregateWrap(sql`${$col.alias}.${sql.identifier("updated_at")}`, spec_downvote.attributes.updated_at.codec) + }; + fieldArgs.apply($col); + } + } + }, + PostToManyCommentFilter: { + every: { + applyPlan($where, fieldArgs) { + assertAllowed47(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery.notPlan().andPlan()); + } + }, + some: { + applyPlan($where, fieldArgs) { + assertAllowed47(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + none: { + applyPlan($where, fieldArgs) { + assertAllowed47(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + aggregates: { + applyPlan($where, fieldArgs) { + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = new PgAggregateConditionStep($where, { + sql, + tableExpression, + alias + }, pgWhereConditionSpecListToSQL); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + } + }, + PostToManyDownvoteFilter: { + every: { + applyPlan($where, fieldArgs) { + assertAllowed48(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery.notPlan().andPlan()); + } + }, + some: { + applyPlan($where, fieldArgs) { + assertAllowed48(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + none: { + applyPlan($where, fieldArgs) { + assertAllowed48(fieldArgs, "object"); + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = $where.notPlan().existsPlan({ + tableExpression, + alias + }); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + }, + aggregates: { + applyPlan($where, fieldArgs) { + if (!$where.extensions.pgFilterRelation) throw new Error("Invalid use of filter, 'pgFilterRelation' expected"); + const { + localAttributes, + remoteAttributes, + tableExpression, + alias + } = $where.extensions.pgFilterRelation, + $subQuery = new PgAggregateConditionStep($where, { + sql, + tableExpression, + alias + }, pgWhereConditionSpecListToSQL); + localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = remoteAttributes[i]; + $subQuery.where(sql`${$where.alias}.${sql.identifier(localAttribute)} = ${$subQuery.alias}.${sql.identifier(remoteAttribute)}`); + }); + fieldArgs.apply($subQuery); + } + } + }, + UpvoteConnection: { + __assertStep: ConnectionStep, + nodes($connection) { + return $connection.nodes(); + }, + edges($connection) { + return $connection.edges(); + }, + pageInfo($connection) { + return $connection.pageInfo(); + }, + totalCount($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + }, + aggregates($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").single(); + }, + groupedAggregates: { + plan($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate"); + }, + args: { + groupBy: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect, input) { + var _a, _b; + const val = input.getRaw().eval(); + if (!Array.isArray(val)) throw new Error("Invalid!"); + for (const group of val) { + const config = getEnumValueConfig(UpvoteGroupBy, group), + plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; + if (typeof plan === "function") plan($pgSelect); + } + return null; + } + }, + having: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect) { + return $pgSelect.havingPlan(); + } + } + } + } + }, + Upvote: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.Upvote.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Upvote.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); + }, + postId($record) { + return $record.get("post_id"); + }, + userId($record) { + return $record.get("user_id"); + }, + createdAt($record) { + return $record.get("created_at"); + }, + updatedAt($record) { + return $record.get("updated_at"); + }, + post($record) { + return pgResource_postPgResource.get({ + id: $record.get("post_id") + }); + }, + user($record) { + return pgResource_userPgResource.get({ + id: $record.get("user_id") + }); + } + }, + UpvoteEdge: { + __assertStep: assertEdgeCapableStep, + cursor($edge) { + return $edge.cursor(); + }, + node($edge) { + return $edge.node(); + } + }, + PageInfo: { + __assertStep: assertPageInfoCapableStep, + hasNextPage($pageInfo) { + return $pageInfo.hasNextPage(); + }, + hasPreviousPage($pageInfo) { + return $pageInfo.hasPreviousPage(); + }, + startCursor($pageInfo) { + return $pageInfo.startCursor(); + }, + endCursor($pageInfo) { + return $pageInfo.endCursor(); + } + }, + UpvoteAggregates: { + __assertStep: assertPgClassSingleStep, + keys($pgSelectSingle) { + const groups = $pgSelectSingle.getClassStep().getGroups(); + if (groups.length > 0) return $pgSelectSingle.select(sql`json_build_array(${sql.join(groups.map(g => g.fragment), ", ")})`, TYPES.json);else return constant(null); + }, + distinctCount($pgSelectSingle) { + return $pgSelectSingle; + } + }, + UpvoteDistinctCountAggregates: { + rowId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + postId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + createdAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + updatedAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + } + }, + UpvoteGroupBy: { + POST_ID: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan + }, + USER_ID: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan2 + }, + CREATED_AT: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan3 + }, + CREATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan4 + }, + CREATED_AT_TRUNCATED_TO_DAY: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan5 + }, + UPDATED_AT: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan6 + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan7 + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan8 + } + }, + UpvoteHavingInput: { + AND: { + applyPlan($where, input) { + input.apply($where); + return null; + } + }, + OR: { + applyPlan($where, input) { + const $or = new PgOrFilterStep($where); + input.apply($or); + return null; + } + }, + sum: { + applyPlan($having) { + return $having; + } + }, + distinctCount: { + applyPlan($having) { + return $having; + } + }, + min: { + applyPlan($having) { + return $having; + } + }, + max: { + applyPlan($having) { + return $having; + } + }, + average: { + applyPlan($having) { + return $having; + } + }, + stddevSample: { + applyPlan($having) { + return $having; + } + }, + stddevPopulation: { + applyPlan($having) { + return $having; + } + }, + varianceSample: { + applyPlan($having) { + return $having; + } + }, + variancePopulation: { + applyPlan($having) { + return $having; + } + } + }, + UpvoteHavingSumInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + HavingDatetimeFilter: { + equalTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + notEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix2()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + greaterThan: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix3()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + greaterThanOrEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix4()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + lessThan: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix5()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + }, + lessThanOrEqualTo: { + applyPlan($booleanFilter, input) { + const val = input.get(); + $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix6()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); + } + } + }, + UpvoteHavingDistinctCountInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingMinInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingMaxInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingAverageInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingStddevSampleInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingStddevPopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingVarianceSampleInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteHavingVariancePopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + UpvoteOrderBy: { + NATURAL: { + applyPlan() {} + }, + PRIMARY_KEY_ASC: { + applyPlan(step) { + upvoteUniques[0].attributes.forEach(attributeName => { + const attribute = upvoteCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + PRIMARY_KEY_DESC: { + applyPlan(step) { + upvoteUniques[0].attributes.forEach(attributeName => { + const attribute = upvoteCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + ROW_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + ROW_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + POST_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + POST_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USER_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + USER_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + CREATED_AT_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "created_at", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + CREATED_AT_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "created_at", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + UPDATED_AT_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + UPDATED_AT_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + } }, - PageInfo: { - __assertStep: assertPageInfoCapableStep, - hasNextPage($pageInfo) { - return $pageInfo.hasNextPage(); + UpvoteCondition: { + rowId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true }, - hasPreviousPage($pageInfo) { - return $pageInfo.hasPreviousPage(); + postId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.post_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true }, - startCursor($pageInfo) { - return $pageInfo.startCursor(); + userId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "user_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.user_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "created_at", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "created_at", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.created_at.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "updated_at", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.updated_at.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + } + }, + UserOrganizationConnection: { + __assertStep: ConnectionStep, + nodes($connection) { + return $connection.nodes(); + }, + edges($connection) { + return $connection.edges(); + }, + pageInfo($connection) { + return $connection.pageInfo(); + }, + totalCount($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").singleAsRecord().select(sql`count(*)`, TYPES.bigint, !1); + }, + aggregates($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate").single(); + }, + groupedAggregates: { + plan($connection) { + return $connection.cloneSubplanWithoutPagination("aggregate"); + }, + args: { + groupBy: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect, input) { + var _a, _b; + const val = input.getRaw().eval(); + if (!Array.isArray(val)) throw new Error("Invalid!"); + for (const group of val) { + const config = getEnumValueConfig(UserOrganizationGroupBy, group), + plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; + if (typeof plan === "function") plan($pgSelect); + } + return null; + } + }, + having: { + autoApplyAfterParentPlan: true, + applyPlan(_$parent, $pgSelect) { + return $pgSelect.havingPlan(); + } + } + } + } + }, + UserOrganizationEdge: { + __assertStep: assertEdgeCapableStep, + cursor($edge) { + return $edge.cursor(); }, - endCursor($pageInfo) { - return $pageInfo.endCursor(); + node($edge) { + return $edge.node(); } }, - UpvoteAggregates: { + UserOrganizationAggregates: { __assertStep: assertPgClassSingleStep, keys($pgSelectSingle) { const groups = $pgSelectSingle.getClassStep().getGroups(); @@ -15062,19 +17699,14 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle; } }, - UpvoteDistinctCountAggregates: { - rowId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, - sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); - return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); - }, - postId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + UserOrganizationDistinctCountAggregates: { + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, - userId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + organizationId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("organization_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, @@ -15082,40 +17714,26 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); - }, - updatedAt($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, - sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); - return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); } }, - UpvoteGroupBy: { - POST_ID: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan - }, + UserOrganizationGroupBy: { USER_ID: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan2 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan + }, + ORGANIZATION_ID: { + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan2 }, CREATED_AT: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan3 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan3 }, CREATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan4 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan4 }, CREATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan5 - }, - UPDATED_AT: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan6 - }, - UPDATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan7 - }, - UPDATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UpvoteGroupBy_extensions_grafast_applyPlan8 + applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan5 } }, - UpvoteHavingInput: { + UserOrganizationHavingInput: { AND: { applyPlan($where, input) { input.apply($where); @@ -15175,255 +17793,96 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UpvoteHavingSumInput: { - createdAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - } - }, - HavingDatetimeFilter: { - equalTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - notEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix2()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - greaterThan: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix3()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - greaterThanOrEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix4()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - lessThan: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix5()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - }, - lessThanOrEqualTo: { - applyPlan($booleanFilter, input) { - const val = input.get(); - $booleanFilter.having(sql`(${sql.parens($booleanFilter.expression)} ${infix6()} ${$booleanFilter.placeholder(val, TYPES.timestamptz)})`); - } - } - }, - UpvoteHavingDistinctCountInput: { + UserOrganizationHavingSumInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingMinInput: { + UserOrganizationHavingDistinctCountInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingMaxInput: { + UserOrganizationHavingMinInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingAverageInput: { + UserOrganizationHavingMaxInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingStddevSampleInput: { + UserOrganizationHavingAverageInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingStddevPopulationInput: { + UserOrganizationHavingStddevSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingVarianceSampleInput: { + UserOrganizationHavingStddevPopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UpvoteHavingVariancePopulationInput: { + UserOrganizationHavingVarianceSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.created_at.codec); - return new PgBooleanFilterStep($having, aggregateExpression); - } - }, - updatedAt: { - applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_upvote.attributes.updated_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } - }, - UpvoteOrderBy: { - NATURAL: { - applyPlan() {} - }, - PRIMARY_KEY_ASC: { - applyPlan(step) { - upvoteUniques[0].attributes.forEach(attributeName => { - const attribute = upvoteCodec.attributes[attributeName]; - step.orderBy({ - codec: attribute.codec, - fragment: sql`${step}.${sql.identifier(attributeName)}`, - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - }); - step.setOrderIsUnique(); - } - }, - PRIMARY_KEY_DESC: { - applyPlan(step) { - upvoteUniques[0].attributes.forEach(attributeName => { - const attribute = upvoteCodec.attributes[attributeName]; - step.orderBy({ - codec: attribute.codec, - fragment: sql`${step}.${sql.identifier(attributeName)}`, - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - }); - step.setOrderIsUnique(); - } - }, - ROW_ID_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "id", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (true) plan.setOrderIsUnique(); - } - }, - ROW_ID_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "id", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (true) plan.setOrderIsUnique(); + }, + UserOrganizationHavingVariancePopulationInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); } + } + }, + UserOrganizationOrderBy: { + NATURAL: { + applyPlan() {} }, - POST_ID_ASC: { + USER_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "post_id", + attribute: "user_id", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15432,11 +17891,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - POST_ID_DESC: { + USER_ID_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "post_id", + attribute: "user_id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15445,11 +17904,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - USER_ID_ASC: { + ORGANIZATION_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "organization_id", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15458,11 +17917,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - USER_ID_DESC: { + ORGANIZATION_ID_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "organization_id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15496,73 +17955,9 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); if (false) plan.setOrderIsUnique(); } - }, - UPDATED_AT_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "updated_at", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } - }, - UPDATED_AT_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "updated_at", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } } }, - UpvoteCondition: { - rowId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true - }, - postId: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "post_id", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "post_id", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.post_id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true - }, + UserOrganizationCondition: { userId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ @@ -15575,45 +17970,45 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "user_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.user_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.user_id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - createdAt: { + organizationId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "organization_id", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "organization_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.created_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.organization_id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - updatedAt: { + createdAt: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "updated_at", + attribute: "created_at", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "updated_at", + attribute: "created_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_upvote.attributes.updated_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.created_at.codec)}`; } }); }, @@ -15621,7 +18016,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, - UserOrganizationConnection: { + CommentConnection: { __assertStep: ConnectionStep, nodes($connection) { return $connection.nodes(); @@ -15650,7 +18045,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const val = input.getRaw().eval(); if (!Array.isArray(val)) throw new Error("Invalid!"); for (const group of val) { - const config = getEnumValueConfig(UserOrganizationGroupBy, group), + const config = getEnumValueConfig(CommentGroupBy, group), plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; if (typeof plan === "function") plan($pgSelect); } @@ -15666,7 +18061,42 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UserOrganizationEdge: { + Comment: { + __assertStep: assertPgClassSingleStep, + id($parent) { + const specifier = nodeIdHandlerByTypeName.Comment.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Comment.codec.name].encode); + }, + rowId($record) { + return $record.get("id"); + }, + message($record) { + return $record.get("message"); + }, + postId($record) { + return $record.get("post_id"); + }, + userId($record) { + return $record.get("user_id"); + }, + createdAt($record) { + return $record.get("created_at"); + }, + updatedAt($record) { + return $record.get("updated_at"); + }, + post($record) { + return pgResource_postPgResource.get({ + id: $record.get("post_id") + }); + }, + user($record) { + return pgResource_userPgResource.get({ + id: $record.get("user_id") + }); + } + }, + CommentEdge: { __assertStep: assertEdgeCapableStep, cursor($edge) { return $edge.cursor(); @@ -15675,7 +18105,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $edge.node(); } }, - UserOrganizationAggregates: { + CommentAggregates: { __assertStep: assertPgClassSingleStep, keys($pgSelectSingle) { const groups = $pgSelectSingle.getClassStep().getGroups(); @@ -15685,14 +18115,24 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle; } }, - UserOrganizationDistinctCountAggregates: { - userId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, + CommentDistinctCountAggregates: { + rowId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, - organizationId($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("organization_id")}`, + message($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("message")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.text); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + postId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + userId($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("user_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, @@ -15700,26 +18140,43 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("created_at")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); + }, + updatedAt($pgSelectSingle) { + const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("updated_at")}`, + sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.timestamptz); + return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); } }, - UserOrganizationGroupBy: { - USER_ID: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan + CommentGroupBy: { + MESSAGE: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan }, - ORGANIZATION_ID: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan2 + POST_ID: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan2 + }, + USER_ID: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan3 }, CREATED_AT: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan3 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan4 }, CREATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan4 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan5 }, CREATED_AT_TRUNCATED_TO_DAY: { - applyPlan: UserOrganizationGroupBy_extensions_grafast_applyPlan5 + applyPlan: CommentGroupBy_extensions_grafast_applyPlan6 + }, + UPDATED_AT: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan7 + }, + UPDATED_AT_TRUNCATED_TO_HOUR: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan8 + }, + UPDATED_AT_TRUNCATED_TO_DAY: { + applyPlan: CommentGroupBy_extensions_grafast_applyPlan9 } }, - UserOrganizationHavingInput: { + CommentHavingInput: { AND: { applyPlan($where, input) { input.apply($where); @@ -15779,96 +18236,191 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - UserOrganizationHavingSumInput: { + CommentHavingSumInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + CommentHavingDistinctCountInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + CommentHavingMinInput: { + createdAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + } + }, + CommentHavingMaxInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } - } - }, - UserOrganizationHavingDistinctCountInput: { - createdAt: { + }, + updatedAt: { applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingMinInput: { + CommentHavingAverageInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } - } - }, - UserOrganizationHavingMaxInput: { - createdAt: { + }, + updatedAt: { applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingAverageInput: { + CommentHavingStddevSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } - } - }, - UserOrganizationHavingStddevSampleInput: { - createdAt: { + }, + updatedAt: { applyPlan($having) { - const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingStddevPopulationInput: { + CommentHavingStddevPopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingVarianceSampleInput: { + CommentHavingVarianceSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationHavingVariancePopulationInput: { + CommentHavingVariancePopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_userOrganization.attributes.created_at.codec); + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + return new PgBooleanFilterStep($having, aggregateExpression); + } + }, + updatedAt: { + applyPlan($having) { + const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - UserOrganizationOrderBy: { + CommentOrderBy: { NATURAL: { applyPlan() {} }, - USER_ID_ASC: { + PRIMARY_KEY_ASC: { + applyPlan(step) { + commentUniques[0].attributes.forEach(attributeName => { + const attribute = commentCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + PRIMARY_KEY_DESC: { + applyPlan(step) { + commentUniques[0].attributes.forEach(attributeName => { + const attribute = commentCodec.attributes[attributeName]; + step.orderBy({ + codec: attribute.codec, + fragment: sql`${step}.${sql.identifier(attributeName)}`, + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + }); + step.setOrderIsUnique(); + } + }, + ROW_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "id", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15877,11 +18429,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - USER_ID_DESC: { + ROW_ID_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "user_id", + attribute: "id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15890,11 +18442,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - ORGANIZATION_ID_ASC: { + MESSAGE_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "organization_id", + attribute: "message", direction: "ASC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15903,11 +18455,63 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (false) plan.setOrderIsUnique(); } }, - ORGANIZATION_ID_DESC: { + MESSAGE_DESC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); plan.orderBy({ - attribute: "organization_id", + attribute: "message", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POST_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POST_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "post_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + USER_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + USER_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "user_id", direction: "DESC", ...(undefined != null ? { nulls: undefined ? "LAST" : "FIRST" @@ -15941,9 +18545,92 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); if (false) plan.setOrderIsUnique(); } + }, + UPDATED_AT_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + UPDATED_AT_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "updated_at", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } } }, - UserOrganizationCondition: { + CommentCondition: { + rowId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + message: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "message", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "message", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.message.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($condition, val) { + if (val.getRaw().evalIs(null)) $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} is null`; + } + });else $condition.where({ + type: "attribute", + attribute: "post_id", + callback(expression) { + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.post_id.codec)}`; + } + }); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, userId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ @@ -15956,45 +18643,45 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "user_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.user_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.user_id.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - organizationId: { + createdAt: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "organization_id", + attribute: "created_at", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "organization_id", + attribute: "created_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.organization_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.created_at.codec)}`; } }); }, autoApplyAfterParentInputPlan: true, autoApplyAfterParentApplyPlan: true }, - createdAt: { + updatedAt: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "updated_at", callback(expression) { return sql`${expression} is null`; } });else $condition.where({ type: "attribute", - attribute: "created_at", + attribute: "updated_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_userOrganization.attributes.created_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.updated_at.codec)}`; } }); }, @@ -16002,7 +18689,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, - CommentConnection: { + DownvoteConnection: { __assertStep: ConnectionStep, nodes($connection) { return $connection.nodes(); @@ -16031,7 +18718,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const val = input.getRaw().eval(); if (!Array.isArray(val)) throw new Error("Invalid!"); for (const group of val) { - const config = getEnumValueConfig(CommentGroupBy, group), + const config = getEnumValueConfig(DownvoteGroupBy, group), plan = (_b = (_a = config === null || config === void 0 ? void 0 : config.extensions) === null || _a === void 0 ? void 0 : _a.grafast) === null || _b === void 0 ? void 0 : _b.applyPlan; if (typeof plan === "function") plan($pgSelect); } @@ -16047,18 +18734,15 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - Comment: { + Downvote: { __assertStep: assertPgClassSingleStep, id($parent) { - const specifier = nodeIdHandlerByTypeName.Comment.plan($parent); - return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Comment.codec.name].encode); + const specifier = nodeIdHandlerByTypeName.Downvote.plan($parent); + return lambda(specifier, nodeIdCodecs[nodeIdHandlerByTypeName.Downvote.codec.name].encode); }, rowId($record) { return $record.get("id"); }, - message($record) { - return $record.get("message"); - }, postId($record) { return $record.get("post_id"); }, @@ -16082,7 +18766,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }); } }, - CommentEdge: { + DownvoteEdge: { __assertStep: assertEdgeCapableStep, cursor($edge) { return $edge.cursor(); @@ -16091,7 +18775,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $edge.node(); } }, - CommentAggregates: { + DownvoteAggregates: { __assertStep: assertPgClassSingleStep, keys($pgSelectSingle) { const groups = $pgSelectSingle.getClassStep().getGroups(); @@ -16101,17 +18785,12 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle; } }, - CommentDistinctCountAggregates: { + DownvoteDistinctCountAggregates: { rowId($pgSelectSingle) { const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); }, - message($pgSelectSingle) { - const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("message")}`, - sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.text); - return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); - }, postId($pgSelectSingle) { const sqlAttribute = sql.fragment`${$pgSelectSingle.getClassStep().alias}.${sql.identifier("post_id")}`, sqlAggregate = aggregateSpec.sqlAggregateWrap(sqlAttribute, TYPES.uuid); @@ -16133,36 +18812,33 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; return $pgSelectSingle.select(sqlAggregate, TYPES.bigint); } }, - CommentGroupBy: { - MESSAGE: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan - }, + DownvoteGroupBy: { POST_ID: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan2 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan }, USER_ID: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan3 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan2 }, CREATED_AT: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan4 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan3 }, CREATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan5 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan4 }, CREATED_AT_TRUNCATED_TO_DAY: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan6 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan5 }, UPDATED_AT: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan7 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan6 }, UPDATED_AT_TRUNCATED_TO_HOUR: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan8 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan7 }, UPDATED_AT_TRUNCATED_TO_DAY: { - applyPlan: CommentGroupBy_extensions_grafast_applyPlan9 + applyPlan: DownvoteGroupBy_extensions_grafast_applyPlan8 } }, - CommentHavingInput: { + DownvoteHavingInput: { AND: { applyPlan($where, input) { input.apply($where); @@ -16222,158 +18898,158 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - CommentHavingSumInput: { + DownvoteHavingSumInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec2.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingDistinctCountInput: { + DownvoteHavingDistinctCountInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingMinInput: { + DownvoteHavingMinInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec3.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingMaxInput: { + DownvoteHavingMaxInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec4.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingAverageInput: { + DownvoteHavingAverageInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec5.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingStddevSampleInput: { + DownvoteHavingStddevSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec6.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingStddevPopulationInput: { + DownvoteHavingStddevPopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec7.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingVarianceSampleInput: { + DownvoteHavingVarianceSampleInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec8.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentHavingVariancePopulationInput: { + DownvoteHavingVariancePopulationInput: { createdAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("created_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.created_at.codec); + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.created_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } }, updatedAt: { applyPlan($having) { const attributeExpression = sql.fragment`${$having.alias}.${sql.identifier("updated_at")}`, - aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_comment.attributes.updated_at.codec); + aggregateExpression = aggregateSpec9.sqlAggregateWrap(attributeExpression, spec_downvote.attributes.updated_at.codec); return new PgBooleanFilterStep($having, aggregateExpression); } } }, - CommentOrderBy: { + DownvoteOrderBy: { NATURAL: { applyPlan() {} }, PRIMARY_KEY_ASC: { applyPlan(step) { - commentUniques[0].attributes.forEach(attributeName => { - const attribute = commentCodec.attributes[attributeName]; + downvoteUniques[0].attributes.forEach(attributeName => { + const attribute = downvoteCodec.attributes[attributeName]; step.orderBy({ codec: attribute.codec, fragment: sql`${step}.${sql.identifier(attributeName)}`, @@ -16388,8 +19064,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; }, PRIMARY_KEY_DESC: { applyPlan(step) { - commentUniques[0].attributes.forEach(attributeName => { - const attribute = commentCodec.attributes[attributeName]; + downvoteUniques[0].attributes.forEach(attributeName => { + const attribute = downvoteCodec.attributes[attributeName]; step.orderBy({ codec: attribute.codec, fragment: sql`${step}.${sql.identifier(attributeName)}`, @@ -16428,32 +19104,6 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; if (true) plan.setOrderIsUnique(); } }, - MESSAGE_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "message", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } - }, - MESSAGE_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "message", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) - }); - if (false) plan.setOrderIsUnique(); - } - }, POST_ID_ASC: { applyPlan(plan) { if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); @@ -16464,7 +19114,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (false) plan.setOrderIsUnique(); + if (true) plan.setOrderIsUnique(); } }, POST_ID_DESC: { @@ -16477,7 +19127,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (false) plan.setOrderIsUnique(); + if (true) plan.setOrderIsUnique(); } }, USER_ID_ASC: { @@ -16559,7 +19209,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - CommentCondition: { + DownvoteCondition: { rowId: { applyPlan($condition, val) { if (val.getRaw().evalIs(null)) $condition.where({ @@ -16572,26 +19222,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.id.codec)}`; - } - }); - }, - autoApplyAfterParentInputPlan: true, - autoApplyAfterParentApplyPlan: true - }, - message: { - applyPlan($condition, val) { - if (val.getRaw().evalIs(null)) $condition.where({ - type: "attribute", - attribute: "message", - callback(expression) { - return sql`${expression} is null`; - } - });else $condition.where({ - type: "attribute", - attribute: "message", - callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.message.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_downvote.attributes.id.codec)}`; } }); }, @@ -16610,7 +19241,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "post_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.post_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_downvote.attributes.post_id.codec)}`; } }); }, @@ -16629,7 +19260,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "user_id", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.user_id.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_downvote.attributes.user_id.codec)}`; } }); }, @@ -16648,7 +19279,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "created_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.created_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_downvote.attributes.created_at.codec)}`; } }); }, @@ -16667,7 +19298,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; type: "attribute", attribute: "updated_at", callback(expression) { - return sql`${expression} = ${$condition.placeholder(val.get(), spec_comment.attributes.updated_at.codec)}`; + return sql`${expression} = ${$condition.placeholder(val.get(), spec_downvote.attributes.updated_at.codec)}`; } }); }, @@ -17513,8 +20144,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17533,8 +20164,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17554,8 +20185,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17576,8 +20207,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17598,8 +20229,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17620,8 +20251,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17642,8 +20273,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17664,8 +20295,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17686,8 +20317,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17708,8 +20339,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17730,8 +20361,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17752,8 +20383,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17774,8 +20405,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17796,8 +20427,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17818,8 +20449,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -17840,8 +20471,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation3.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation3.remoteAttributes[i]; + relation4.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation4.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18497,8 +21128,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18517,8 +21148,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18538,8 +21169,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18560,8 +21191,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18582,8 +21213,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18604,8 +21235,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18626,8 +21257,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18648,8 +21279,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18670,8 +21301,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18692,8 +21323,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18714,8 +21345,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18736,8 +21367,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18758,8 +21389,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18780,8 +21411,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18802,8 +21433,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18824,8 +21455,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18846,8 +21477,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18868,8 +21499,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_projectPgResource.name)); - relation4.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation4.remoteAttributes[i]; + relation5.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation5.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_projectPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18889,8 +21520,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18909,8 +21540,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18930,8 +21561,8 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18952,8 +21583,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18974,8 +21605,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -18996,8 +21627,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -19018,8 +21649,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -19040,8 +21671,8 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation5.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation5.remoteAttributes[i]; + relation6.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation6.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); @@ -19596,473 +22227,733 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; nulls: undefined ? "LAST" : "FIRST" } : null) }); - if (false) plan.setOrderIsUnique(); + if (false) plan.setOrderIsUnique(); + } + }, + HIDRA_ID_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "hidra_id", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + HIDRA_ID_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "hidra_id", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USERNAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "username", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + USERNAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "username", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (true) plan.setOrderIsUnique(); + } + }, + FIRST_NAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "first_name", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + FIRST_NAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "first_name", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + LAST_NAME_ASC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "last_name", + direction: "ASC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + LAST_NAME_DESC: { + applyPlan(plan) { + if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); + plan.orderBy({ + attribute: "last_name", + direction: "DESC", + ...(undefined != null ? { + nulls: undefined ? "LAST" : "FIRST" + } : null) + }); + if (false) plan.setOrderIsUnique(); + } + }, + POSTS_COUNT_ASC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "ASC" + }); + } + }, + POSTS_COUNT_DESC: { + applyPlan($select) { + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + $select.orderBy({ + fragment, + codec: TYPES.bigint, + direction: "DESC" + }); + } + }, + POSTS_DISTINCT_COUNT_ROW_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + direction: "ASC" + }); + } + }, + POSTS_DISTINCT_COUNT_ROW_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + direction: "DESC" + }); + } + }, + POSTS_DISTINCT_COUNT_TITLE_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + direction: "ASC" + }); } }, - HIDRA_ID_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "hidra_id", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_TITLE_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (true) plan.setOrderIsUnique(); - } - }, - HIDRA_ID_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "hidra_id", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + direction: "DESC" }); - if (true) plan.setOrderIsUnique(); } }, - USERNAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "username", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_DESCRIPTION_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + direction: "ASC" }); - if (true) plan.setOrderIsUnique(); } }, - USERNAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "username", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_DESCRIPTION_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + direction: "DESC" }); - if (true) plan.setOrderIsUnique(); } }, - FIRST_NAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "first_name", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_PROJECT_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + direction: "ASC" }); - if (false) plan.setOrderIsUnique(); } }, - FIRST_NAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "first_name", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_PROJECT_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + direction: "DESC" }); - if (false) plan.setOrderIsUnique(); } }, - LAST_NAME_ASC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "last_name", - direction: "ASC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_USER_ID_ASC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + direction: "ASC" }); - if (false) plan.setOrderIsUnique(); } }, - LAST_NAME_DESC: { - applyPlan(plan) { - if (!(plan instanceof PgSelectStep) && !(plan instanceof PgUnionAllStep)) throw new Error("Expected a PgSelectStep or PgUnionAllStep when applying ordering value"); - plan.orderBy({ - attribute: "last_name", - direction: "DESC", - ...(undefined != null ? { - nulls: undefined ? "LAST" : "FIRST" - } : null) + POSTS_DISTINCT_COUNT_USER_ID_DESC: { + applyPlan($select) { + var _a, _b; + const foreignTableAlias = $select.alias, + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; + conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); + }); + if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} +from ${pgResource_postPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + $select.orderBy({ + fragment, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + direction: "DESC" }); - if (false) plan.setOrderIsUnique(); } }, - POSTS_COUNT_ASC: { + POSTS_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, direction: "ASC" }); } }, - POSTS_COUNT_DESC: { + POSTS_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_ROW_ID_ASC: { + POSTS_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_ROW_ID_DESC: { + POSTS_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + relation7.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation7.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_post.attributes.id.codec)} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} from ${pgResource_postPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_TITLE_ASC: { + UPVOTES_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_upvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_TITLE_DESC: { + UPVOTES_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("title")}`, spec_post.attributes.title.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_upvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.title.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.title.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_DESCRIPTION_ASC: { + UPVOTES_DISTINCT_COUNT_ROW_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_DESCRIPTION_DESC: { + UPVOTES_DISTINCT_COUNT_ROW_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("description")}`, spec_post.attributes.description.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.description.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.description.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_PROJECT_ID_ASC: { + UPVOTES_DISTINCT_COUNT_POST_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_PROJECT_ID_DESC: { + UPVOTES_DISTINCT_COUNT_POST_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("project_id")}`, spec_post.attributes.project_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.project_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.project_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_USER_ID_ASC: { + UPVOTES_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_USER_ID_DESC: { + UPVOTES_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_post.attributes.user_id.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_CREATED_AT_ASC: { + UPVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_CREATED_AT_DESC: { + UPVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_post.attributes.created_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, direction: "DESC" }); } }, - POSTS_DISTINCT_COUNT_UPDATED_AT_ASC: { + UPVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, direction: "ASC" }); } }, - POSTS_DISTINCT_COUNT_UPDATED_AT_DESC: { + UPVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_postPgResource.name)); - relation6.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation6.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); + relation8.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation8.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_postPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_post.attributes.updated_at.codec)} -from ${pgResource_postPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} +from ${pgResource_upvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_post.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_post.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, direction: "DESC" }); } }, - UPVOTES_COUNT_ASC: { + USER_ORGANIZATIONS_COUNT_ASC: { applyPlan($select) { const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent`select count(*) -from ${pgResource_upvotePgResource.from} ${tableAlias} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, @@ -20071,18 +22962,18 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; }); } }, - UPVOTES_COUNT_DESC: { + USER_ORGANIZATIONS_COUNT_DESC: { applyPlan($select) { const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent`select count(*) -from ${pgResource_upvotePgResource.from} ${tableAlias} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, @@ -20091,698 +22982,698 @@ where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; }); } }, - UPVOTES_DISTINCT_COUNT_ROW_ID_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_ROW_ID_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_upvote.attributes.id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_POST_ID_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_POST_ID_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_upvote.attributes.post_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_USER_ID_ASC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_USER_ID_DESC: { + USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); + relation9.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation9.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_upvote.attributes.user_id.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} +from ${resource_user_organizationPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { + COMMENTS_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { + COMMENTS_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_upvote.attributes.created_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.created_at.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - UPVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { + COMMENTS_DISTINCT_COUNT_ROW_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, direction: "ASC" }); } }, - UPVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { + COMMENTS_DISTINCT_COUNT_ROW_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_upvotePgResource.name)); - relation7.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation7.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_upvotePgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_upvote.attributes.updated_at.codec)} -from ${pgResource_upvotePgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_upvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_upvote.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_COUNT_ASC: { + COMMENTS_DISTINCT_COUNT_MESSAGE_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${resource_user_organizationPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_COUNT_DESC: { + COMMENTS_DISTINCT_COUNT_MESSAGE_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) -from ${resource_user_organizationPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_ASC: { + COMMENTS_DISTINCT_COUNT_POST_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_USER_ID_DESC: { + COMMENTS_DISTINCT_COUNT_POST_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_userOrganization.attributes.user_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_ASC: { + COMMENTS_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_ORGANIZATION_ID_DESC: { + COMMENTS_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("organization_id")}`, spec_userOrganization.attributes.organization_id.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.organization_id.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.organization_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, direction: "DESC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_ASC: { + COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, direction: "ASC" }); } }, - USER_ORGANIZATIONS_DISTINCT_COUNT_CREATED_AT_DESC: { + COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, - conditions = [], - tableAlias = sql.identifier(Symbol(resource_user_organizationPgResource.name)); - relation8.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation8.remoteAttributes[i]; + conditions = [], + tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof resource_user_organizationPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_userOrganization.attributes.created_at.codec)} -from ${resource_user_organizationPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} +from ${pgResource_commentPgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_userOrganization.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_userOrganization.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, direction: "DESC" }); } }, - COMMENTS_COUNT_ASC: { + COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} from ${pgResource_commentPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, direction: "ASC" }); } }, - COMMENTS_COUNT_DESC: { + COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { + var _a, _b; const foreignTableAlias = $select.alias, conditions = [], tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + relation10.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation10.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent`select count(*) + const fragment = sql`(${sql.indent` +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} from ${pgResource_commentPgResource.from} ${tableAlias} -where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; +where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: TYPES.bigint, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_ROW_ID_ASC: { + DOWNVOTES_COUNT_ASC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, + codec: TYPES.bigint, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_ROW_ID_DESC: { + DOWNVOTES_COUNT_DESC: { applyPlan($select) { - var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); - const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_comment.attributes.id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} -where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); + const fragment = sql`(${sql.indent`select count(*) +from ${pgResource_downvotePgResource.from} ${tableAlias} +where ${sql.parens(sql.join(conditions.map(c => sql.parens(c)), " AND "))}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.id.codec, + codec: TYPES.bigint, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_MESSAGE_ASC: { + DOWNVOTES_DISTINCT_COUNT_ROW_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_downvote.attributes.id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.id.codec, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_MESSAGE_DESC: { + DOWNVOTES_DISTINCT_COUNT_ROW_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("message")}`, spec_comment.attributes.message.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("id")}`, spec_downvote.attributes.id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.message.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.message.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.id.codec, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_POST_ID_ASC: { + DOWNVOTES_DISTINCT_COUNT_POST_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_downvote.attributes.post_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.post_id.codec, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_POST_ID_DESC: { + DOWNVOTES_DISTINCT_COUNT_POST_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_comment.attributes.post_id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("post_id")}`, spec_downvote.attributes.post_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.post_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.post_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.post_id.codec, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_USER_ID_ASC: { + DOWNVOTES_DISTINCT_COUNT_USER_ID_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_downvote.attributes.user_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.user_id.codec, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_USER_ID_DESC: { + DOWNVOTES_DISTINCT_COUNT_USER_ID_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_comment.attributes.user_id.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("user_id")}`, spec_downvote.attributes.user_id.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.user_id.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.user_id.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.user_id.codec, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_CREATED_AT_ASC: { + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_downvote.attributes.created_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.created_at.codec, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_CREATED_AT_DESC: { + DOWNVOTES_DISTINCT_COUNT_CREATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_comment.attributes.created_at.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("created_at")}`, spec_downvote.attributes.created_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.created_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.created_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.created_at.codec, direction: "DESC" }); } }, - COMMENTS_DISTINCT_COUNT_UPDATED_AT_ASC: { + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_ASC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_downvote.attributes.updated_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.updated_at.codec, direction: "ASC" }); } }, - COMMENTS_DISTINCT_COUNT_UPDATED_AT_DESC: { + DOWNVOTES_DISTINCT_COUNT_UPDATED_AT_DESC: { applyPlan($select) { var _a, _b; const foreignTableAlias = $select.alias, conditions = [], - tableAlias = sql.identifier(Symbol(pgResource_commentPgResource.name)); - relation9.localAttributes.forEach((localAttribute, i) => { - const remoteAttribute = relation9.remoteAttributes[i]; + tableAlias = sql.identifier(Symbol(pgResource_downvotePgResource.name)); + relation11.localAttributes.forEach((localAttribute, i) => { + const remoteAttribute = relation11.remoteAttributes[i]; conditions.push(sql.fragment`${tableAlias}.${sql.identifier(remoteAttribute)} = ${foreignTableAlias}.${sql.identifier(localAttribute)}`); }); - if (typeof pgResource_commentPgResource.from === "function") throw new Error("Function source unsupported"); + if (typeof pgResource_downvotePgResource.from === "function") throw new Error("Function source unsupported"); const fragment = sql`(${sql.indent` -select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_comment.attributes.updated_at.codec)} -from ${pgResource_commentPgResource.from} ${tableAlias} +select ${aggregateSpec.sqlAggregateWrap(sql.fragment`${tableAlias}.${sql.identifier("updated_at")}`, spec_downvote.attributes.updated_at.codec)} +from ${pgResource_downvotePgResource.from} ${tableAlias} where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; $select.orderBy({ fragment, - codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_comment.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_comment.attributes.updated_at.codec, + codec: (_b = (_a = aggregateSpec.pgTypeCodecModifier) === null || _a === void 0 ? void 0 : _a.call(aggregateSpec, spec_downvote.attributes.updated_at.codec)) !== null && _b !== void 0 ? _b : spec_downvote.attributes.updated_at.codec, direction: "DESC" }); } @@ -20942,6 +23833,23 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + createDownvote: { + plan(_, args) { + const plan = object({ + result: pgInsertSingle(pgResource_downvotePgResource, Object.create(null)) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + autoApplyAfterParentPlan: true, + applyPlan(_, $object) { + return $object; + } + } + } + }, createUpvote: { plan(_, args) { const plan = object({ @@ -21063,10 +23971,63 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, + updateDownvoteById: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_downvotePgResource, specFromArgs(args)) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + updateDownvote: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_downvotePgResource, { + id: args.get(['input', "rowId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + updateDownvoteByPostIdAndUserId: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_downvotePgResource, { + post_id: args.get(['input', "postId"]), + user_id: args.get(['input', "userId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, updateUpvoteById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_upvotePgResource, specFromArgs(args)) + result: pgUpdateSingle(pgResource_upvotePgResource, specFromArgs2(args)) }); args.apply(plan); return plan; @@ -21119,7 +24080,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateOrganizationById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_organizationPgResource, specFromArgs2(args)) + result: pgUpdateSingle(pgResource_organizationPgResource, specFromArgs3(args)) }); args.apply(plan); return plan; @@ -21189,7 +24150,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateCommentById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_commentPgResource, specFromArgs3(args)) + result: pgUpdateSingle(pgResource_commentPgResource, specFromArgs4(args)) }); args.apply(plan); return plan; @@ -21223,7 +24184,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updatePostById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_postPgResource, specFromArgs4(args)) + result: pgUpdateSingle(pgResource_postPgResource, specFromArgs5(args)) }); args.apply(plan); return plan; @@ -21257,7 +24218,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateUserById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_userPgResource, specFromArgs5(args)) + result: pgUpdateSingle(pgResource_userPgResource, specFromArgs6(args)) }); args.apply(plan); return plan; @@ -21327,7 +24288,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; updateProjectById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_projectPgResource, specFromArgs6(args)) + result: pgUpdateSingle(pgResource_projectPgResource, specFromArgs7(args)) }); args.apply(plan); return plan; @@ -21358,12 +24319,66 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - updateProjectByName: { + updateProjectByName: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_projectPgResource, { + name: args.get(['input', "name"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + updateProjectBySlugAndOrganizationId: { + plan(_$root, args) { + const plan = object({ + result: pgUpdateSingle(pgResource_projectPgResource, { + slug: args.get(['input', "slug"]), + organization_id: args.get(['input', "organizationId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + deleteUserOrganizationByUserIdAndOrganizationId: { + plan(_$root, args) { + const plan = object({ + result: pgDeleteSingle(resource_user_organizationPgResource, { + user_id: args.get(['input', "userId"]), + organization_id: args.get(['input', "organizationId"]) + }) + }); + args.apply(plan); + return plan; + }, + args: { + input: { + applyPlan(_, $object) { + return $object; + } + } + } + }, + deleteDownvoteById: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_projectPgResource, { - name: args.get(['input', "name"]) - }) + result: pgDeleteSingle(pgResource_downvotePgResource, specFromArgs8(args)) }); args.apply(plan); return plan; @@ -21376,12 +24391,11 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - updateProjectBySlugAndOrganizationId: { + deleteDownvote: { plan(_$root, args) { const plan = object({ - result: pgUpdateSingle(pgResource_projectPgResource, { - slug: args.get(['input', "slug"]), - organization_id: args.get(['input', "organizationId"]) + result: pgDeleteSingle(pgResource_downvotePgResource, { + id: args.get(['input', "rowId"]) }) }); args.apply(plan); @@ -21395,12 +24409,12 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; } } }, - deleteUserOrganizationByUserIdAndOrganizationId: { + deleteDownvoteByPostIdAndUserId: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(resource_user_organizationPgResource, { - user_id: args.get(['input', "userId"]), - organization_id: args.get(['input', "organizationId"]) + result: pgDeleteSingle(pgResource_downvotePgResource, { + post_id: args.get(['input', "postId"]), + user_id: args.get(['input', "userId"]) }) }); args.apply(plan); @@ -21417,7 +24431,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteUpvoteById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_upvotePgResource, specFromArgs7(args)) + result: pgDeleteSingle(pgResource_upvotePgResource, specFromArgs9(args)) }); args.apply(plan); return plan; @@ -21470,7 +24484,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteOrganizationById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_organizationPgResource, specFromArgs8(args)) + result: pgDeleteSingle(pgResource_organizationPgResource, specFromArgs10(args)) }); args.apply(plan); return plan; @@ -21540,7 +24554,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteCommentById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_commentPgResource, specFromArgs9(args)) + result: pgDeleteSingle(pgResource_commentPgResource, specFromArgs11(args)) }); args.apply(plan); return plan; @@ -21574,7 +24588,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deletePostById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_postPgResource, specFromArgs10(args)) + result: pgDeleteSingle(pgResource_postPgResource, specFromArgs12(args)) }); args.apply(plan); return plan; @@ -21608,7 +24622,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteUserById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_userPgResource, specFromArgs11(args)) + result: pgDeleteSingle(pgResource_userPgResource, specFromArgs13(args)) }); args.apply(plan); return plan; @@ -21678,7 +24692,7 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; deleteProjectById: { plan(_$root, args) { const plan = object({ - result: pgDeleteSingle(pgResource_projectPgResource, specFromArgs12(args)) + result: pgDeleteSingle(pgResource_projectPgResource, specFromArgs14(args)) }); args.apply(plan); return plan; @@ -21799,6 +24813,95 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, + CreateDownvotePayload: { + __assertStep: assertExecutableStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + downvote($object) { + return $object.get("result"); + }, + query() { + return rootValue(); + }, + downvoteEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = downvoteUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_downvotePgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + CreateDownvoteInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + }, + autoApplyAfterParentApplyPlan: true + }, + downvote: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + }, + autoApplyAfterParentApplyPlan: true + } + }, + DownvoteInput: { + "__inputPlan": function DownvoteInput_inputPlan() { + return object(Object.create(null)); + }, + rowId: { + applyPlan($insert, val) { + $insert.set("id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($insert, val) { + $insert.set("post_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($insert, val) { + $insert.set("user_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($insert, val) { + $insert.set("created_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($insert, val) { + $insert.set("updated_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + } + }, CreateUpvotePayload: { __assertStep: assertExecutableStep, clientMutationId($mutation) { @@ -22441,6 +25544,121 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; autoApplyAfterParentApplyPlan: true } }, + UpdateDownvotePayload: { + __assertStep: ObjectStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + downvote($object) { + return $object.get("result"); + }, + query() { + return rootValue(); + }, + downvoteEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = downvoteUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_downvotePgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + UpdateDownvoteByIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + id: undefined, + patch: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + } + } + }, + DownvotePatch: { + "__inputPlan": function DownvotePatch_inputPlan() { + return object(Object.create(null)); + }, + rowId: { + applyPlan($insert, val) { + $insert.set("id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + postId: { + applyPlan($insert, val) { + $insert.set("post_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + userId: { + applyPlan($insert, val) { + $insert.set("user_id", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + createdAt: { + applyPlan($insert, val) { + $insert.set("created_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + }, + updatedAt: { + applyPlan($insert, val) { + $insert.set("updated_at", val.get()); + }, + autoApplyAfterParentInputPlan: true, + autoApplyAfterParentApplyPlan: true + } + }, + UpdateDownvoteInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + rowId: undefined, + patch: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + } + } + }, + UpdateDownvoteByPostIdAndUserIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + postId: undefined, + userId: undefined, + patch: { + applyPlan($object) { + return $object.getStepForKey("result").setPlan(); + } + } + }, UpdateUpvotePayload: { __assertStep: ObjectStep, clientMutationId($mutation) { @@ -23217,6 +26435,71 @@ where ${sql.join(conditions.map(c => sql.parens(c)), " AND ")}`})`; userId: undefined, organizationId: undefined }, + DeleteDownvotePayload: { + __assertStep: ObjectStep, + clientMutationId($mutation) { + return $mutation.getStepForKey("clientMutationId", !0) ?? constant(null); + }, + downvote($object) { + return $object.get("result"); + }, + deletedDownvoteId($object) { + const $record = $object.getStepForKey("result"), + specifier = nodeIdHandlerByTypeName.Downvote.plan($record); + return lambda(specifier, nodeIdCodecs_base64JSON_base64JSON.encode); + }, + query() { + return rootValue(); + }, + downvoteEdge: { + plan($mutation, args, info) { + const $result = $mutation.getStepForKey("result", !0); + if (!$result) return constant(null); + const $select = (() => { + if ($result instanceof PgDeleteSingleStep) return pgSelectFromRecord($result.resource, $result.record());else { + const spec = downvoteUniques[0].attributes.reduce((memo, attributeName) => { + memo[attributeName] = $result.get(attributeName); + return memo; + }, Object.create(null)); + return pgResource_downvotePgResource.find(spec); + } + })(), + $value = args.getRaw("orderBy"); + applyOrderToPlan($select, $value, info.schema.getType("DownvoteOrderBy")); + const $connection = connection($select), + $single = $select.row(first($select)); + return new EdgeStep($connection, $single); + }, + args: { + orderBy: undefined + } + } + }, + DeleteDownvoteByIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + id: undefined + }, + DeleteDownvoteInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + rowId: undefined + }, + DeleteDownvoteByPostIdAndUserIdInput: { + clientMutationId: { + applyPlan($input, val) { + $input.set("clientMutationId", val.get()); + } + }, + postId: undefined, + userId: undefined + }, DeleteUpvotePayload: { __assertStep: ObjectStep, clientMutationId($mutation) { diff --git a/src/lib/drizzle/migrations/0003_medical_paper_doll.sql b/src/lib/drizzle/migrations/0003_medical_paper_doll.sql new file mode 100644 index 0000000..eb7394e --- /dev/null +++ b/src/lib/drizzle/migrations/0003_medical_paper_doll.sql @@ -0,0 +1,11 @@ +CREATE TABLE "downvote" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "post_id" uuid NOT NULL, + "user_id" uuid NOT NULL, + "created_at" timestamp(6) with time zone DEFAULT now(), + "updated_at" timestamp(6) with time zone DEFAULT now(), + CONSTRAINT "downvote_postId_userId_unique" UNIQUE("post_id","user_id") +); +--> statement-breakpoint +ALTER TABLE "downvote" ADD CONSTRAINT "downvote_post_id_post_id_fk" FOREIGN KEY ("post_id") REFERENCES "public"."post"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "downvote" ADD CONSTRAINT "downvote_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/src/lib/drizzle/migrations/meta/0003_snapshot.json b/src/lib/drizzle/migrations/meta/0003_snapshot.json new file mode 100644 index 0000000..63c8bc5 --- /dev/null +++ b/src/lib/drizzle/migrations/meta/0003_snapshot.json @@ -0,0 +1,643 @@ +{ + "id": "c3d6effb-2f62-41a2-b761-2021cf198532", + "prevId": "a07ce84b-3633-4339-9d3f-3f1ea87fd405", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.comment": { + "name": "comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "post_id": { + "name": "post_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "comment_post_id_post_id_fk": { + "name": "comment_post_id_post_id_fk", + "tableFrom": "comment", + "tableTo": "post", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_user_id_user_id_fk": { + "name": "comment_user_id_user_id_fk", + "tableFrom": "comment", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.downvote": { + "name": "downvote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "post_id": { + "name": "post_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "downvote_post_id_post_id_fk": { + "name": "downvote_post_id_post_id_fk", + "tableFrom": "downvote", + "tableTo": "post", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "downvote_user_id_user_id_fk": { + "name": "downvote_user_id_user_id_fk", + "tableFrom": "downvote", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "downvote_postId_userId_unique": { + "name": "downvote_postId_userId_unique", + "nullsNotDistinct": false, + "columns": [ + "post_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_name_unique": { + "name": "organization_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + }, + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.post": { + "name": "post", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "post_project_id_project_id_fk": { + "name": "post_project_id_project_id_fk", + "tableFrom": "post", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "post_user_id_user_id_fk": { + "name": "post_user_id_user_id_fk", + "tableFrom": "post", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project": { + "name": "project", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "project_organization_id_organization_id_fk": { + "name": "project_organization_id_organization_id_fk", + "tableFrom": "project", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "project_name_unique": { + "name": "project_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + }, + "project_slug_organizationId_unique": { + "name": "project_slug_organizationId_unique", + "nullsNotDistinct": false, + "columns": [ + "slug", + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.upvote": { + "name": "upvote", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "post_id": { + "name": "post_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "upvote_post_id_post_id_fk": { + "name": "upvote_post_id_post_id_fk", + "tableFrom": "upvote", + "tableTo": "post", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "upvote_user_id_user_id_fk": { + "name": "upvote_user_id_user_id_fk", + "tableFrom": "upvote", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "upvote_postId_userId_unique": { + "name": "upvote_postId_userId_unique", + "nullsNotDistinct": false, + "columns": [ + "post_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "hidra_id": { + "name": "hidra_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_hidraId_unique": { + "name": "user_hidraId_unique", + "nullsNotDistinct": false, + "columns": [ + "hidra_id" + ] + }, + "user_username_unique": { + "name": "user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_organization": { + "name": "user_organization", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp(6) with time zone", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_organization_user_id_user_id_fk": { + "name": "user_organization_user_id_user_id_fk", + "tableFrom": "user_organization", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_organization_organization_id_organization_id_fk": { + "name": "user_organization_organization_id_organization_id_fk", + "tableFrom": "user_organization", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_organization_userId_organizationId_unique": { + "name": "user_organization_userId_organizationId_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "organization_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/src/lib/drizzle/migrations/meta/_journal.json b/src/lib/drizzle/migrations/meta/_journal.json index 323a2fd..9111197 100644 --- a/src/lib/drizzle/migrations/meta/_journal.json +++ b/src/lib/drizzle/migrations/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1735611260906, "tag": "0002_high_ender_wiggin", "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1735658626719, + "tag": "0003_medical_paper_doll", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/lib/drizzle/schema/downvote.table.ts b/src/lib/drizzle/schema/downvote.table.ts new file mode 100644 index 0000000..451598e --- /dev/null +++ b/src/lib/drizzle/schema/downvote.table.ts @@ -0,0 +1,51 @@ +import { relations } from "drizzle-orm"; +import { pgTable, unique, uuid } from "drizzle-orm/pg-core"; + +import { defaultDate, defaultId } from "./constants"; +import { posts } from "./post.table"; +import { users } from "./user.table"; + +import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; + +/** + * Downvote table. Upvotes are used to represent negative sentiment on posts. + */ +export const downvotes = pgTable( + "downvote", + { + id: defaultId(), + postId: uuid() + .notNull() + .references(() => posts.id, { + onDelete: "cascade", + }), + userId: uuid() + .notNull() + .references(() => users.id, { + onDelete: "cascade", + }), + createdAt: defaultDate(), + updatedAt: defaultDate(), + }, + (table) => [unique().on(table.postId, table.userId)] +); + +/** + * Relations for the downvote table. + */ +export const downvoteRelations = relations(downvotes, ({ one }) => ({ + post: one(posts, { + fields: [downvotes.postId], + references: [posts.id], + }), + user: one(users, { + fields: [downvotes.userId], + references: [users.id], + }), +})); + +/** + * Type helpers related to the downvote table. + */ +export type InsertDownvote = InferInsertModel; +export type SelectDownvote = InferSelectModel; diff --git a/src/lib/drizzle/schema/index.ts b/src/lib/drizzle/schema/index.ts index 2728aec..6aac608 100644 --- a/src/lib/drizzle/schema/index.ts +++ b/src/lib/drizzle/schema/index.ts @@ -1,4 +1,5 @@ export * from "./comment.table"; +export * from "./downvote.table"; export * from "./organization.table"; export * from "./post.table"; export * from "./project.table"; diff --git a/src/lib/drizzle/schema/post.table.ts b/src/lib/drizzle/schema/post.table.ts index c961064..61f3c9b 100644 --- a/src/lib/drizzle/schema/post.table.ts +++ b/src/lib/drizzle/schema/post.table.ts @@ -3,6 +3,7 @@ import { pgTable, text, uuid } from "drizzle-orm/pg-core"; import { comments } from "./comment.table"; import { defaultDate, defaultId } from "./constants"; +import { downvotes } from "./downvote.table"; import { projects } from "./project.table"; import { upvotes } from "./upvote.table"; import { users } from "./user.table"; @@ -44,6 +45,7 @@ export const postRelations = relations(posts, ({ one, many }) => ({ }), comments: many(comments), upvotes: many(upvotes), + downvotes: many(downvotes), })); /** diff --git a/src/lib/drizzle/schema/user.table.ts b/src/lib/drizzle/schema/user.table.ts index db4a337..645e29e 100644 --- a/src/lib/drizzle/schema/user.table.ts +++ b/src/lib/drizzle/schema/user.table.ts @@ -1,7 +1,9 @@ import { relations } from "drizzle-orm"; import { pgTable, text, uuid } from "drizzle-orm/pg-core"; +import { comments } from "./comment.table"; import { defaultDate, defaultId } from "./constants"; +import { downvotes } from "./downvote.table"; import { posts } from "./post.table"; import { upvotes } from "./upvote.table"; import { usersToOrganizations } from "./userToOrganization.table"; @@ -28,7 +30,9 @@ export const users = pgTable("user", { export const userRelations = relations(users, ({ many }) => ({ organizations: many(usersToOrganizations), posts: many(posts), + comments: many(comments), upvotes: many(upvotes), + downvotes: many(downvotes), })); /** diff --git a/src/scripts/seedDatabase.ts b/src/scripts/seedDatabase.ts index 3a65f27..b9a2c5a 100644 --- a/src/scripts/seedDatabase.ts +++ b/src/scripts/seedDatabase.ts @@ -56,13 +56,14 @@ const seedDatabase = async () => { }, users: { count: 500, + with: { + upvotes: 10, + downvotes: 10, + }, }, usersToOrganizations: { count: 100, }, - upvotes: { - count: 1000, - }, comments: { columns: { message: f.loremIpsum(), From 28c5613bce03c85f87db014e41f1e80dc39e7c37 Mon Sep 17 00:00:00 2001 From: hobbescodes <87732294+hobbescodes@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:35:46 -0600 Subject: [PATCH 3/7] docs: update downvote table jsdoc Co-authored-by: Brian Cooper <20056195+coopbri@users.noreply.github.com> --- src/lib/drizzle/schema/downvote.table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/drizzle/schema/downvote.table.ts b/src/lib/drizzle/schema/downvote.table.ts index 451598e..9aab720 100644 --- a/src/lib/drizzle/schema/downvote.table.ts +++ b/src/lib/drizzle/schema/downvote.table.ts @@ -8,7 +8,7 @@ import { users } from "./user.table"; import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; /** - * Downvote table. Upvotes are used to represent negative sentiment on posts. + * Downvote table. Downvotes are used to represent negative sentiment on posts. */ export const downvotes = pgTable( "downvote", From 4cb1eb0dee6586733adaeefb573c573f09e15429 Mon Sep 17 00:00:00 2001 From: hobbescodes <87732294+hobbescodes@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:36:55 -0600 Subject: [PATCH 4/7] docs: update comment table jsdoc Co-authored-by: Brian Cooper <20056195+coopbri@users.noreply.github.com> --- src/lib/drizzle/schema/comment.table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/drizzle/schema/comment.table.ts b/src/lib/drizzle/schema/comment.table.ts index 42f7fba..d81aa58 100644 --- a/src/lib/drizzle/schema/comment.table.ts +++ b/src/lib/drizzle/schema/comment.table.ts @@ -8,7 +8,7 @@ import { users } from "./user.table"; import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; /** - * Comment table. Comments reperesent feedback item comments. + * Comment table. Comments serve as units of feedback item discourse. */ export const comments = pgTable("comment", { id: defaultId(), From d6959b1097fc71bcbe504d34e402dc34e592804f Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Wed, 1 Jan 2025 15:12:16 -0600 Subject: [PATCH 5/7] chore(db,user): remove indirect Drizzle relations --- src/lib/drizzle/schema/user.table.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/lib/drizzle/schema/user.table.ts b/src/lib/drizzle/schema/user.table.ts index 645e29e..b21d1bd 100644 --- a/src/lib/drizzle/schema/user.table.ts +++ b/src/lib/drizzle/schema/user.table.ts @@ -1,11 +1,8 @@ import { relations } from "drizzle-orm"; import { pgTable, text, uuid } from "drizzle-orm/pg-core"; -import { comments } from "./comment.table"; import { defaultDate, defaultId } from "./constants"; -import { downvotes } from "./downvote.table"; import { posts } from "./post.table"; -import { upvotes } from "./upvote.table"; import { usersToOrganizations } from "./userToOrganization.table"; import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; @@ -30,9 +27,6 @@ export const users = pgTable("user", { export const userRelations = relations(users, ({ many }) => ({ organizations: many(usersToOrganizations), posts: many(posts), - comments: many(comments), - upvotes: many(upvotes), - downvotes: many(downvotes), })); /** From f447fee5fcdbf16caa042c7894edd671d484156e Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Wed, 1 Jan 2025 15:13:46 -0600 Subject: [PATCH 6/7] Revert "chore(db,user): remove indirect Drizzle relations" This reverts commit d6959b1097fc71bcbe504d34e402dc34e592804f. --- src/lib/drizzle/schema/user.table.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/drizzle/schema/user.table.ts b/src/lib/drizzle/schema/user.table.ts index b21d1bd..645e29e 100644 --- a/src/lib/drizzle/schema/user.table.ts +++ b/src/lib/drizzle/schema/user.table.ts @@ -1,8 +1,11 @@ import { relations } from "drizzle-orm"; import { pgTable, text, uuid } from "drizzle-orm/pg-core"; +import { comments } from "./comment.table"; import { defaultDate, defaultId } from "./constants"; +import { downvotes } from "./downvote.table"; import { posts } from "./post.table"; +import { upvotes } from "./upvote.table"; import { usersToOrganizations } from "./userToOrganization.table"; import type { InferInsertModel, InferSelectModel } from "drizzle-orm"; @@ -27,6 +30,9 @@ export const users = pgTable("user", { export const userRelations = relations(users, ({ many }) => ({ organizations: many(usersToOrganizations), posts: many(posts), + comments: many(comments), + upvotes: many(upvotes), + downvotes: many(downvotes), })); /** From fffecc0407ea935f63d17daea7e7be3db8302ddc Mon Sep 17 00:00:00 2001 From: hobbescodes <87732294+hobbescodes@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:56:20 -0600 Subject: [PATCH 7/7] build: update drizzle-seed dependency --- bun.lockb | Bin 99288 -> 99288 bytes package.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bun.lockb b/bun.lockb index 6d15d4209903f5c41158bbc88e4494d98330a6c1..ed14116a27bbd9663e3ae8f2476e97e84375d643 100755 GIT binary patch delta 144 zcmV;B0B`@;hX&Y(29Pcwlho1+#bgs4Uh+JehB)MW?=RgI-lFjc1AlP<@*AvWu}-El zlQbAKvnVuGTR`z-t<`63VQPYwz_BUdCR6tC@qe&+i*5t>d^30zbHd^sO@L*7SyFq{ y#|J^M|B{g1x&aZPnN1fUosJS==6tigkD_)1GcGW;WS_3mKFt>4F0cRr@;y^k8 delta 144 zcmV;B0B`@;hX&Y(29PcwUx}MrZZPH-5pa(X&U%m{dCgGP&Oag0L`iK+eN#mau}-El zle8E#vnVuGTR=UsAwB=#u|^~PGQ-h`lK}Ym7?|^F@UOxM#aMQ2ZNY%UD+N~<6_Nzl yZp^@AC^@M2UI@f_a}+=cFcY&SJ|nZekD_)1GA=Q;WS_3jJF}HDG0cRuEL_4?u diff --git a/package.json b/package.json index 9e77be3..2364498 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@graphile/simplify-inflection": "^8.0.0-beta.5", "dayjs": "^1.11.13", "drizzle-orm": "^0.38.2", - "drizzle-seed": "^0.2.1", + "drizzle-seed": "^0.3.0", "graphile-export": "^0.0.2-beta.24", "graphql": "^16.9.0", "graphql-yoga": "^5.8.0",