MCPcopy Create free account
hub / github.com/OneBitCodeBlog/onebitlife / createHabit

Function createHabit

src/Services/HabitsService.js:13–39  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

11});
12
13const createHabit = (obj) => {
14 return new Promise((resolve, reject) => {
15 db.transaction((tx) => {
16 tx.executeSql(
17 "INSERT INTO habits (habitArea, habitName, habitFrequency, habitHasNotification, habitNotificationFrequency, habitNotificationTime, lastCheck, daysWithoutChecks, progressBar, habitIsChecked, habitChecks) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
18 [
19 obj.habitArea,
20 obj.habitName,
21 obj.habitFrequency,
22 obj.habitHasNotification,
23 obj.habitNotificationFrequency,
24 obj.habitNotificationTime,
25 obj.lastCheck,
26 obj.daysWithoutChecks,
27 obj.progressBar,
28 obj.habitIsChecked,
29 obj.habitChecks,
30 ],
31 (_, { rowsAffected, insertId }) => {
32 if (rowsAffected > 0) resolve(insertId);
33 else reject("Error inserting obj: " + JSON.stringify(obj));
34 },
35 (_, error) => reject(error)
36 );
37 });
38 });
39};
40
41const findByArea = (habitArea) => {
42 return new Promise((resolve, reject) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected