Skip to content

Commit

Permalink
Updated insertData model - Creating and updating model now works better
Browse files Browse the repository at this point in the history
  • Loading branch information
RFlintstone committed May 24, 2023
1 parent 245b380 commit 73c23f1
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/models/firebase/insert/insertData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,9 @@ async function timestamp() {
}

async function insertData(collection, newID, body) {
let json = {
first_name: body.first_name,
last_name: body.last_name,
age: body.age,
email: body.email,
iban: body.iban,
pin: body.pin,
balance: body.balance,
time: await timestamp()
}

console.log(json)
// Set timestamp and log body
body.time = await timestamp();
console.log(body);

// Make sure we have the right reference
const db = await require('../init/setupFirebase').getDB();
Expand All @@ -29,7 +20,7 @@ async function insertData(collection, newID, body) {

// Insert the data in the newly created document
let state;
await Ref.set(json)
await Ref.set(body, {merge: true})
.then(() => {
// Log our document id
console.log('Added/updated document with id', newID);
Expand Down

0 comments on commit 73c23f1

Please sign in to comment.