Skip to content

[cloud_firestore_odm] update functions doesn't include complex fields #27

@TarekkMA

Description

@TarekkMA

Moved to: firebase/flutterfire#9428

I have modified the [movies model class] as below. The comments field is a nested list now.
(https://github.com/firebase/flutterfire/blob/master/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/movie.dart)

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import 'package:json_annotation/json_annotation.dart';

part 'movie.g.dart';

@JsonSerializable()
class Movie {
  Movie({
    this.genre,
    required this.likes,
    required this.poster,
    required this.rated,
    required this.runtime,
    required this.title,
    required this.year,
    this.comments,
  }) {
    _$assertMovie(this);
  }

  final String poster;
  @Min(0)
  final int likes;
  final String title;
  @Min(0)
  final int year;
  final String runtime;
  final String rated;
  final List<String>? genre;
  final List<Comment>? comments;
}

@Collection<Movie>('firestore-example-app')
final moviesRef = MovieCollectionReference();

@JsonSerializable()
class Comment {
  Comment({
    required this.authorName,
    required this.message,
  });

  final String authorName;
  final String message;

  factory Comment.fromJson(Map<String, dynamic> json) =>
      _$CommentFromJson(json);

  Map<String, dynamic> toJson() => _$CommentToJson(this);
}

as you can see, the update function doesn't include the comments field

  Future<void> update({
    String poster,
    int likes,
    String title,
    int year,
    String runtime,
    String rated,
    List<String>? genre,
  });```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions