javascriptnode.jsfirebasegoogle-cloud-platformgoogle-cloud-firestore

What is Firebase Firestore 'Reference' data type good for?


I'm just exploring the new Firebase Firestore and it contains a data type called reference. It is not clear to me what this does.


Solution

  • References are very much like foreign keys.

    The currently released SDKs cannot store references to other projects. Within a project, references can point to any other document in any other collection.

    You can use references in queries like any other value: for filtering, ordering, and for paging (startAt/startAfter).

    Unlike foreign keys in a SQL database, references are not useful for performing joins in a single query. You can use them for dependent lookups (which seem join like), but be careful because each hop will result in another round trip to the server.