You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to Vue 3 and the composition API and I'm completely new to Pinia (as of yesterday). I am pulling in a collection of records from Firebase without an order (using the ordering built-in to Firebase didn't give me the sort that I wanted due to the way javascript handles sorted strings of numbers (i.e. 01, 09, 1, 2, etc)
import{initializeApp}from'firebase/app';import{collection,doc,getFirestore,setDoc,}from'firebase/firestore';import{defineStore}from'pinia';import{computed}from'vue';import{useCollection}from'vuefire';constfirebaseConfig={// firebaseConfig};constapp=initializeApp(firebaseConfig);constdb=getFirestore(app);consttimeEntriesCollection=collection(db,'time_entries');exportconstuseTimeEntriesStore=defineStore('leaderboard',()=>{consttimeEntries=useCollection(timeEntriesCollection);// `time` is in the format of `"{minutes}:{seconds}"`, e.g. `01:33`constallTimeEntries=computed(()=>timeEntries.value.sort((a,b)=>Number(a.time)-Number(b.time)));asyncfunctionaddTimeEntry(timeEntry){awaitsetDoc(doc(db,'time_entries',timeEntry.id),timeEntry);}return{
addTimeEntry,
allTimeEntries,
timeEntries,};});
I'm not quite sure what's going on. The state matches the getter but it should be sorted properly (at least testing in the console that the numbers are sorted correctly).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to Vue 3 and the composition API and I'm completely new to Pinia (as of yesterday). I am pulling in a collection of records from Firebase without an order (using the ordering built-in to Firebase didn't give me the sort that I wanted due to the way javascript handles sorted strings of numbers (i.e. 01, 09, 1, 2, etc)
The view is pretty basic
I'm not quite sure what's going on. The state matches the getter but it should be sorted properly (at least testing in the console that the numbers are sorted correctly).
Beta Was this translation helpful? Give feedback.
All reactions