MCPcopy Index your code
hub / github.com/simstudioai/sim / addCredits

Function addCredits

apps/sim/lib/billing/credits/balance.ts:73–93  ·  view source on GitHub ↗
(
  entityType: 'user' | 'organization',
  entityId: string,
  amount: number
)

Source from the content-addressed store, hash-verified

71}
72
73export async function addCredits(
74 entityType: 'user' | 'organization',
75 entityId: string,
76 amount: number
77): Promise<void> {
78 if (entityType === 'organization') {
79 await db
80 .update(organization)
81 .set({ creditBalance: sql`${organization.creditBalance} + ${amount}` })
82 .where(eq(organization.id, entityId))
83
84 logger.info('Added credits to organization', { organizationId: entityId, amount })
85 } else {
86 await db
87 .update(userStats)
88 .set({ creditBalance: sql`${userStats.creditBalance} + ${amount}` })
89 .where(eq(userStats.userId, entityId))
90
91 logger.info('Added credits to user', { userId: entityId, amount })
92 }
93}
94
95async function removeCredits(
96 entityType: 'user' | 'organization',

Callers 2

route.tsFile · 0.90

Calls 3

infoMethod · 0.80
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected