-
Notifications
You must be signed in to change notification settings - Fork 5
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
Error when using "reference" type #10
Comments
Hi, not currently. There are some decisions that would have to be made to support this. Since the Given the following setup: export interface AuthorDoc {
readonly id: string
readonly collection: 'authors'
name: string
}
export interface PostsDoc {
readonly id: string
readonly collection: 'posts'
title: string
authorRef: DocumentReference
}
export class AuthorDataSource extends FirestoreDataStore<AuthourDoc, ApolloContext> {}
export class PostsDataSource extends FirestoreDataStore<PostsDoc, ApolloContext> {}
const authorsDS = new AuthorDataSource(firestore.collection('authors'))
const postsDS = new PostsDataSource(firestore.collection('posts')) The "correct" behaviour would probably look something like this: const post = await postsDS.findOne('abc123')
const author = await authorsDS.findOne(post.authorRef) However, what happens if we do const post = await postsDS.findOne('abc123')
const author = await postsDS.findOne(post.authorRef) does it
And then, if it does (1), should it do so in a "deep" fashion? My personal solution at the moment is storing |
I have reference to objects from a foreign collection. How can I use Firestore Reference type for the ID.
With the above, I get the above error which is expected:
ID cannot represent value: { _firestore: { _settings: [Object], _settingsFrozen: true, _serializer: [Serializer], _projectId: "taffi-stage", registeredListenersCount: 0, bulkWritersCount: 0, _backoffSettings: [Object], _clientPool: [ClientPool] }, _path: { segments: [Array] }, _converter: { toFirestore: [function toFirestore], fromFirestore: [function fromFirestore] } }
Is there a way for me to use Firestore "Reference Type" as the ID to refer to a document from foreign collection ?
Thank you.
The text was updated successfully, but these errors were encountered: