Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Adds created_at & updated_at timestamp on records #3

Merged
merged 2 commits into from
Jul 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/restClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default (trackedResources = [], firebaseConfig = {}) => {

case UPDATE:
console.log(type, params)
const updatedData = Object.assign({}, resourcesData[resource][params.id], params.data)
const updatedData = Object.assign({updated_at: Date.now()}, resourcesData[resource][params.id], params.data)
firebase.database().ref(params.basePath + '/' + params.id).update(updatedData)
.then(() => {
resolve({
Expand All @@ -123,7 +123,7 @@ export default (trackedResources = [], firebaseConfig = {}) => {

case CREATE:
const newItemKey = firebase.database().ref().child(params.basePath).push().key;
const createdData = Object.assign({}, params.data, { id: newItemKey, key: newItemKey })
const createdData = Object.assign({created_at: Date.now(), updated_at: Date.now()}, params.data, { id: newItemKey, key: newItemKey })
firebase.database().ref(params.basePath + '/' + newItemKey).update(createdData)
.then(() => {
resolve({
Expand Down