forked from wovalle/fireorm
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support for Referenced Properties #14
Labels
bug
Something isn't working
enhancement
New feature or request
from_willyovale
An issue described in original project, but never implemented
Comments
elersong
added
bug
Something isn't working
enhancement
New feature or request
from_willyovale
An issue described in original project, but never implemented
labels
Jul 13, 2024
Additional Context
@Collection()
class Band {
id: string;
@DocumentReference()
artist: Reference<Artist>;
}
// Creating a reference with a string
getRepository(Band).create({
id: 'fireorm rocks!',
artist: '/artists/wovalle'
});
// Creating a reference with an object
const artist = new Artist();
artist.id = 'new-artist';
artist.name = 'New Artist';
getRepository(Band).create({
id: 'fireorm rocks!',
artist: setReference(artist),
}); Proposed API Changes
@Collection()
class Band {
id: string;
@DocumentReference()
artist: Reference<Artist>;
}
// Example with reference path as string
getRepository(Band).create({
id: 'fireorm rocks!',
artist: '/artists/wovalle'
});
// Example with reference object
const artist = new Artist();
artist.id = 'new-artist';
artist.name = 'New Artist';
getRepository(Band).create({
id: 'fireorm rocks!',
artist: setReference(artist),
});
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
enhancement
New feature or request
from_willyovale
An issue described in original project, but never implemented
Description
Fireorm currently does not support creating entities with referenced properties directly. Users need a way to reference other collections when creating new documents, such as referencing a
Produtor
from within aProdutorDadosAdicionais
entity.Steps to Reproduce
Produtor
class and aProdutorDadosAdicionais
class, withProdutorDadosAdicionais
having a property referencingProdutor
.ProdutorDadosAdicionais
document with a reference to an existingProdutor
document.Expected Behavior
Ability to create documents with referenced properties that correctly store document references in Firestore.
Actual Behavior
Currently, there is no straightforward way to set referenced properties, leading to workarounds or potential bugs with deserialization/serialization of Firestore entities.
Acceptance Criteria
getRef/getPath
function to entities for easy access to document paths.Additional Context
produtorId
andprodutorNome
properties.Reference<T>
type and@DocumentReference()
decorator.Original
The text was updated successfully, but these errors were encountered: