question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat(reducers): support reference data type

See original GitHub issue

hello

Do you want to request a feature or report a bug?
feature

What is the current behavior? data type

db.collection("posts").doc("QyJJKtQhNA2QeHFVqfCR") = {
  content: String,
  author: Reference // 'users/jRjjlMyTBENjvln3pQpGwKgdvAa2'
}

query

{ collection: 'posts', doc: postId }

result

{ content: '', author: DocumentReference }

A DocumentReference refers to a document location in a Firestore database and can be used to write, read, or listen to the location. The document at the referenced location may or may not exist. A DocumentReference can also be used to create a CollectionReference to a subcollection.

image

What is the expected behavior?

{ content: '', author: { displayName: '', avatarUrl: '' } }

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
sergeytsivincommented, Mar 11, 2019

Once I have realized that populates parameter could be a function I have created a workaround:


const collection = 'todos';
const populates = (dataKey, originalData) => {
    if (originalData && originalData['owner'] && !originalData['ownerData']) {
        originalData['ownerData'] = originalData.owner.path.split('/')[1];
    }
    return [{child: 'ownerData', root: 'users'}]
};

const mapStateToProps = state => {
    return {
        uid: state.firebase.auth.uid,
        todos: populate(state.firestore, collection, populates)
    }
};
const enhancer = compose(
    firestoreConnect([{collection, populates}]),
    connect(mapStateToProps),
);

This code first extracts the user document ID from the owner attribute and then uses this ID to initialize a new ownerData attribute. Finally ownerData attribute is populated as usual.

3reactions
prescottpruecommented, Jun 4, 2018

@jollyBaker Not yet, but definitely high on the priority list.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding the magic behind StoreModule of NgRx ...
In this article we're going to dive deep into the internals of @ngrx/store package. We'll examine how state, reducers, store and actions work...
Read more >
Primitive Data Types (The Java™ Tutorials > Learning the ...
The eight primitive data types supported by the Java programming language are: byte: The byte data type is an 8-bit signed two's complement...
Read more >
Boston Gear: Speed Reducer, Gear Drive, Variable Speed ...
Boston Gear offers the industry's largest line up of reliable speed reducers, gearing and other quality drivetrain components. With well over a century...
Read more >
Creating reference data types for sets - IBM
Enter a Name for this reference data type. For the Data type, select Reference Data Sets. For Owners, click Manage Owners to select...
Read more >
pmndrs/zustand: Bear necessities for state ... - GitHub
A small, fast and scalable bearbones state-management solution using simplified flux principles. Has a comfy api based on hooks, isn't boilerplatey or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found