MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / upsertOrganization

Function upsertOrganization

apps/cloud/src/auth/user-store.ts:108–125  ·  view source on GitHub ↗
(org: OrganizationPayload)

Source from the content-addressed store, hash-verified

106 // written — never re-minted live, never renamed. A row the mirror does not
107 // hold is minted live (`insertOrganization`).
108 const upsertOrganization = async (org: OrganizationPayload) => {
109 const existing = await getOrganization(org.id);
110 if (existing) {
111 if (existing.deletedAt !== null) return existing;
112 const [updated] = await db
113 .update(organizations)
114 .set({ name: org.name, workosUpdatedAt: org.updatedAt })
115 .where(and(eq(organizations.id, org.id), organizationAcceptsName(org.updatedAt)))
116 .returning();
117 return updated ?? existing;
118 }
119 return insertOrganization(db, {
120 id: org.id,
121 name: org.name,
122 workosUpdatedAt: org.updatedAt,
123 deletedAt: null,
124 });
125 };
126
127 return {
128 // --- Accounts ---

Callers

nothing calls this directly

Calls 5

getOrganizationFunction · 0.85
organizationAcceptsNameFunction · 0.85
insertOrganizationFunction · 0.85
setMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected