MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / create

Method create

lib/models/expenses.ts:89–118  ·  view source on GitHub ↗
(userId: string, name: string, month: string, value: number)

Source from the content-addressed store, hash-verified

87 }
88
89 static async create(userId: string, name: string, month: string, value: number) {
90 const extra: Budget['extra'] = {
91 usedValue: 0,
92 availableValue: value,
93 };
94
95 const newBudget = (await db.query<Budget>(
96 sql`INSERT INTO "bewcloud_budgets" (
97 "user_id",
98 "name",
99 "month",
100 "value",
101 "extra"
102 ) VALUES ($1, $2, $3, $4, $5)
103 RETURNING *`,
104 [
105 userId,
106 name,
107 month,
108 value,
109 JSON.stringify(extra),
110 ],
111 ))[0];
112
113 // Numeric values come as strings, so we need to convert them to numbers
114 return {
115 ...newBudget,
116 value: Number(newBudget.value),
117 };
118 }
119
120 static async update(
121 budget: Budget,

Callers 3

createMethod · 0.45
updateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected