Proper way to update query with Pinia #1391
-
| What is proper way to update Firebase query inside Pinia? So for example i want to add button to asc/desc orders. export const useNotesStore = defineStore('notes', () => {
  // State
  const list = useCollection<Note>(query(notesRef, orderBy('created_at', 'asc')), {
    ssrKey: 'notes'
  });
});And i want after clicking from a component  | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            Blinks44
          
      
      
        Jul 19, 2023 
      
    
    Replies: 1 comment
-
| Ok, mixing getters and state can achieve this, why i didn't realize it before... Something like this:   const order = ref('asc');
  const listQuery = computed(() => {
    return query(notesRef, orderBy('created_at', order.value));
  });
  const list = useCollection<Note>(listQuery, {
    ssrKey: 'notes'
  }); | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        Blinks44
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Ok, mixing getters and state can achieve this, why i didn't realize it before... Something like this: