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.

Identifier conversion not considered during `@DocumentReference` construction

See original GitHub issue

Hi,

I use the new feature of document reference annotation @DocumentReference and have a issue about it. In case I have Country and City documents and City referenced to Country with this annotation. But “_Id” field of type on Country document is ObjectId. I write this code on City document as well:

@DocumentReference
private Country country;

When I get Country of City object it couldn’t fetch data and return null. Because of Country document reference stored as String type. I think there is a type mismatch on lookup query.

I think we need like 2 options on document reference.

  1. dataType parameter on DocumentReference annotation class. (example : ObjectId, String …)
  2. Or custom lookup field.
@DocumentReference(lookup = "{ '_id' : new ObjectId('?#{#target}') }")
private Country country;

or

@DocumentReference(lookup = "{ '_id' : { $oid: '?#{#target}' } }")
private Country country;
  1. Spring should get the data type of referenced document and according to prepare lookup query

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
blueiceprjcommented, Aug 25, 2021

Than you for your quick response

1reaction
blueiceprjcommented, Aug 24, 2021

Ok. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - How to convert Firebase Document Reference to ...
Now to implement the same in my app, I would like to know how to convert the Firebase Document Reference to Firebase Query...
Read more >
DocumentReference - FHIR v5.0.0-cibuild
A reference to a document of any kind for any purpose. ... The DocumentReference resource provides metadata about the document so that the...
Read more >
Class DocumentReference (2.7.3) | Python client library
A reference to a document in a Firestore database. The document may already exist or can be created by this class. Parameters. Name,...
Read more >
DocumentReference - FHIR v4.0.1
PDF documents , Scanned Paper, and digital records of faxes; Clinical Notes in various forms; Image files (e.g., JPEG, GIF, TIFF); Non-Standard formats...
Read more >
RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
This specification does not define a generative grammar for URIs; ... transcribe a resource identifier from one medium to another has been considered...
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