GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

Firestore: Reference-field support (e.g. similar to @DBref from mongodb)

Open
#1,224 1 comment 0 reactions 0 assignees View on GitHub
firestore priority: p3 type: enhancement
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Is your feature request related to a problem? Please describe.**
Currently, there seems to be no way to tag fields as foreign keys / references, although firestore has an explicit "datatype" reference. Instead, all sub-objects CRUD operations are executed by value (e.g. the full object is inserted as a child element). References would be needed for real e.g. many-to-many relationships etc., though.

**Describe the solution you'd like**
A simple annotation like mongodb's [@DBRef](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/mapping/DBRef.html) would make the possibly easiest-to-use solution.

**Describe alternatives you've considered**
As a workaround, one could implement additional service methods that store a manual foreign _id fields instead of the full objects but this is cumbersome to implement. Another solution could be DTO objects that include referenced objects "by value" with a custom mapper that maps them to manual references internally.

**Additional context**
None.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by locating the existing Firestore object-mapping implementation and its tests, then determine how annotations and reference-valued fields are currently handled. Done means a defined annotation-based reference model supports the requested relationship behavior with coverage for the relevant CRUD operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.