You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to create my models where I have a list of references in Firestore?
In Firestore I have:
Collection People:
- name (String)
- active (bool)
Collection Projects
- name (String)
- active (bool)
- people (Array of references -> each is a person)
- - '/people/xsiuhuhfs'
On my Dart code, I have my model:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
part 'project_model.g.dart';
@JsonSerializable(explicitToJson: true)
class Project {
Project({
required this.name,
required this.active,
required this.people,
});
String name;
bool active;
// Here is the problem, I don't have a List of person. I have a list of _JsonDocumentReference!
List<Person> people;
factory Project.fromJson(Map<String, Object?> json) =>
_$ProjectFromJson(json);
Map<String, Object?> toJson() => _$ProjectToJson(this);
}
@Collection<Project>('projects')
final ProjectCollectionReference projectsRef = ProjectCollectionReference();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I think this is related to @AirborneEagle question on #7475 (comment) but it wasn't understood.
Is there a way to create my models where I have a list of references in Firestore?
In Firestore I have:
On my Dart code, I have my model:
Is there a way to convert this to reference?
Beta Was this translation helpful? Give feedback.
All reactions