(obj)
| 11 | }); |
| 12 | |
| 13 | const 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 | |
| 41 | const findByArea = (habitArea) => { |
| 42 | return new Promise((resolve, reject) => { |
nothing calls this directly
no outgoing calls
no test coverage detected