firestore_odm_annotation 1.0.0
firestore_odm_annotation: ^1.0.0 copied to clipboard
Pure annotations for Firestore ODM code generation. Provides the core annotations used to generate type-safe Firestore ODM code.
Firestore ODM Annotation #
Pure annotations for Firestore ODM code generation. This package provides the core annotations used to generate type-safe Firestore ODM code.
Installation #
Add this to your package's pubspec.yaml
file:
dependencies:
firestore_odm_annotation: ^1.0.0
Usage #
This package provides annotations to mark your classes for Firestore ODM code generation:
import 'package:firestore_odm_annotation/firestore_odm_annotation.dart';
@Collection('users')
class User {
const User({
required this.name,
required this.email,
});
final String name;
final String email;
}
Available Annotations #
@Collection(path)
- Marks a class as a Firestore collection@SubCollection(path)
- Marks a class as a Firestore subcollection@DocumentId()
- Marks a field as the document ID@FirestoreField(name)
- Maps a field to a different Firestore field name
Code Generation #
To generate the ODM code, you'll also need:
dev_dependencies:
firestore_odm_builder: ^1.0.0
build_runner: ^2.4.0
Then run:
dart run build_runner build
Features #
- Type-safe Firestore operations
- Automatic serialization/deserialization
- Query builder support
- Real-time updates
- Subcollection support