Skip to content

[cloud_firestore_odm] Preserving @Id Decorated Field while Using cloud_firestore_odm #11939

@yelkamel

Description

@yelkamel

Hello Flutterfire Community,

I am currently working on a project that extensively uses cloud_firestore_odm, and have come across a scenario wherein I would like to keep the field decorated with @id in the Firestore document data.

The issue arises with the generated code:

  static Map<String, Object?> toFirestore(
    User value,
    SetOptions? options,
  ) {
    return {...value.toJson()}..remove('uid');
  }

Here, the uid field, which is the @id decorated in my case, is consistently removed with every document update.

Upon referring to the Firestore documentation, it becomes evident that the @id field is not included in the Firestore object when encoded, by default. However, my requirement contradicts this default behavior, and I would like to preserve the @id field.

Could anyone guide me on how to stop cloud_firestore_odm from removing the uid field, which is marked with @id annotation, when encoding a Document? Any input on this would be greatly appreciated.

Thanks in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: allIssues / PRs which are for all platforms.plugin: odmresolution: userThis was a user issue, e.g. invalid configuration or code.type: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions