Many fixes n stuff

This commit is contained in:
mcarquigny
2025-03-20 17:37:01 +01:00
parent 56a251b929
commit 70ff43ba3a
5 changed files with 31 additions and 50 deletions

View File

@ -1,11 +1,5 @@
import { pb } from 'src/boot/pocketbase'
//
// export function loadAppData (store) {
// return Firebase.database().ref().once('value').then((snapshot) => {
// store.commit('setFirebaseState', snapshot.val())
// })
// }
//
export async function loadAppData (store) {
return Promise.all([
pb.collection('stock').getFullList(),
@ -20,42 +14,18 @@ export async function loadAppData (store) {
})
}
// export function addToCollection (store, data) {
// return Firebase.database().ref('/' + data.collection).once('value').then((snapshot) => {
// let index = parseInt(Object.keys(snapshot.val()).reverse()[0]) + 1
// return Firebase.database().ref('/' + data.collection + '/' + index).set(data.data)
// })
// }
//
export function addToCollection (store, data) {
return pb.collection(data.collection).create(data.data)
}
// export function removeFromCollection (store, data) {
// return Firebase.database().ref('/' + data.collection).once('value').then((snapshot) => {
// let index = snapshot.val().findIndex(item =>
// item.timestamp === data.data.timestamp && item.ref === data.data.ref
// )
// return Firebase.database().ref('/' + data.collection + '/' + index).remove()
// })
// }
export function removeFromCollection (store, data) {
return pb.collection(data.collection).delete(data.data.id)
}
//
// export function updateItem (store, data) {
// return Firebase.database().ref(`/${data.collection}/${data.itemId}`).set(data.data)
// }
//
export function updateItem (store, data) {
return pb.collection(data.collection).update(data.data.id, data.data)
}
// export function deleteItem (store, data) {
// return Firebase.database().ref(`/${data.collection}/${data.itemId}`).set(null)
// }
//
export function deleteItem (store, data) {
return pb.collection(data.collection).delete(data.data.id)
}