mesqueeb / vuex-easy-firestore

Easy coupling of firestore and a vuex module. 2-way sync with 0 boilerplate!
https://mesqueeb.github.io/vuex-easy-firestore
MIT License
234 stars 28 forks source link

Module naming and firestore structure #314

Closed RobSteward closed 4 years ago

RobSteward commented 4 years ago

Hi,

I have the following firestore collection structure:

collection 1
collection 2
collection 3
settings (collection)
   -- global (doc)
      -- preserveState : true (prop)
      -- someOtherSetting : true
   -- map (doc)
      -- type: "map"
      -- maxFileSize: 2000000

my vuex module looks like this:

const settings = {
    firestorePath: 'settings',
    firestoreRefType: 'collection',
    moduleName: 'settings',
    statePropName: 'settings',
    namespaced: true,
}

export default settings

The "problem" here is that referencing this from my store now looks like this:

console.log(`This object is a ${{this.$store.state.settings.settings.mapSettings.type}}`)

This looks clumsy and inefficient.

Is there a better way to organize this?

mesqueeb commented 4 years ago

@RobSteward hey! this really comes down to personal preferences, but what I always do is: whatever the module is (collection/doc) always use "data" as statePropName. Then it would be state.settings.data instead of state.settings.settings.

I hope this helps!

(i'll close the issue, but feel free to keep the conversation going)

BTW, organisation, naming and access be much improved in v2.0, which I'm working on hard now 😉

--
Vuex Easy Firestore was made with ♥ by Luca Ban.
If you use this library in your projects, you can support the maintenance of this library by a small contribution via Github 💜.
You can also reach out on twitter if you want a one-on-one coding review/lesson. 🦜