Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying which references are automatically bound to avoid right errors #281

Open
hs-sundeep opened this issue May 23, 2019 · 4 comments
Labels

Comments

@hs-sundeep
Copy link

Currently if a reference data type's depth is not more than maxRefDepth then it is by default binded. Instead there should be a way to override default behavior and specify the keys of the fields which should be binded.

@posva
Copy link
Member

posva commented May 23, 2019

Will have to think about a convenient api to customize keys that works well with nested documents

@posva posva added feature request firestore new Cloud Store labels May 23, 2019
@trickstival
Copy link
Collaborator

trickstival commented Jun 2, 2019

I'm still reading vuefire internals, but I had some ideas

Dataset

There're two collections: people and sabers.
There's a document called "Luke" inside "people" collection. Its data looks like this:

{ 
  name: 'Luke',
  father: ref_to_darth_vader_doc,
  saber: ref_to_saber_doc 
}

Rules

I only want to retrieve father, cause my user can only read people collection, not saber

Ideas

1 - My first idea was to create an "exclude" option, where you pass the keys you want to exclude:

export default {
  data () {
    luke: null
  },
  methods: {
    bindLuke () {
      const options = {
        excludeKeys: ['saber']
      }
      this.$bind('luke', database.collection('people').doc(lukeId), options)
    }
  }
}

2 - Passing only keys is easier, but when handling subcollections this solution is not scalable. Maybe if we filter it by which document the reference is referring to it becomes better.

For instance, we can use wildcards just like firebase rules to exclude entire collections from the binding:

const options = {
  excludePaths: ['sabers/{saberId}']
}

This second option only works if we want to exclude the ref cause the user doesn't have access to it.
But if we want to exclude the ref loading cause it's too large or any other reason it becomes hard to select which keys to keep, cause the document might contain different keys referring to the same collection.

3 - So, my third idea is to use the wildcards syntax but for the keys path, not collections path:

const options = {
  excludePaths: ['people/[wildcard or luke id]/saber']
}

4 - Maybe it could work without wildcards, but with references. But the implementation is not very clear to me:

const options = {
  exclude: [{ collection: database.collection('people'), key: 'saber' }]
}
// or even
const options = {
  exclude: [{ collection: 'people', key: 'saber' }]
}

@posva posva changed the title Option to specify which reference data types should be binded Allow specifying which references are automatically bound to avoid right errors Jun 30, 2019
@dominik-korsa
Copy link

What's the progress of this?

@trevorparscal
Copy link

I came here to suggest this, but found it's been suggested. It seems like it wouldn't be very hard to do - I may even give it a shot. But before I dig in, does anyone know if this is already being considered or worked on for the next version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants