{"id":20532370,"url":"https://github.com/unitvectory-labs/firestoreproto2map","last_synced_at":"2026-03-05T16:33:17.341Z","repository":{"id":233209556,"uuid":"786277327","full_name":"UnitVectorY-Labs/firestoreproto2map","owner":"UnitVectorY-Labs","description":"Helper library to convert Firestore Protocol Buffer from event to map that can be used by Firestore","archived":false,"fork":false,"pushed_at":"2024-09-14T12:36:37.000Z","size":157,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-14T22:45:02.697Z","etag":null,"topics":["gcp-firestore","java-17"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UnitVectorY-Labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-14T00:41:22.000Z","updated_at":"2024-09-14T12:36:32.000Z","dependencies_parsed_at":"2024-04-14T17:28:14.401Z","dependency_job_id":"25a5da36-88f5-4d68-892a-7933a1043791","html_url":"https://github.com/UnitVectorY-Labs/firestoreproto2map","commit_stats":null,"previous_names":["unitvectory-labs/firestoreproto2map"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2Ffirestoreproto2map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2Ffirestoreproto2map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2Ffirestoreproto2map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnitVectorY-Labs%2Ffirestoreproto2map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnitVectorY-Labs","download_url":"https://codeload.github.com/UnitVectorY-Labs/firestoreproto2map/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242138802,"owners_count":20078007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcp-firestore","java-17"],"created_at":"2024-11-16T00:14:33.105Z","updated_at":"2026-03-05T16:33:17.331Z","avatar_url":"https://github.com/UnitVectorY-Labs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub release](https://img.shields.io/github/release/UnitVectorY-Labs/firestoreproto2map.svg)](https://github.com/UnitVectorY-Labs/firestoreproto2map/releases/latest) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Active](https://img.shields.io/badge/Status-Active-green)](https://guide.unitvectorylabs.com/bestpractices/status/#active) [![Maven Central](https://img.shields.io/maven-central/v/com.unitvectory/firestoreproto2map)](https://central.sonatype.com/artifact/com.unitvectory/firestoreproto2map) [![javadoc](https://javadoc.io/badge2/com.unitvectory/firestoreproto2map/javadoc.svg)](https://javadoc.io/doc/com.unitvectory/firestoreproto2map) [![codecov](https://codecov.io/gh/UnitVectorY-Labs/firestoreproto2map/graph/badge.svg?token=1PXHW608HT)](https://codecov.io/gh/UnitVectorY-Labs/firestoreproto2map)\n\n# firestoreproto2map\n\nJava helper library to convert Firestore Protocol Buffer from event to map that can be used by Firestore\n\n## Purpose\n\nThis library takes the Protocol Buffer sent from Firestore for a document and converts it to a Java Map Object. Firestore stores the underlying documents as Protocol Buffers and therefore that is what is sent to a Cloud Function when subscribed. If you want to take this and insert it back into Firestore it must be converted to a compatible object, that is what this library does.\n\n## Getting Started\n\nThis library requires Java 17 and is available in the Maven Central Repository:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.unitvectory\u003c/groupId\u003e\n    \u003cartifactId\u003efirestoreproto2map\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.5\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\n```java\npackage functions;\n\nimport com.google.cloud.functions.CloudEventsFunction;\nimport com.google.events.cloud.firestore.v1.DocumentEventData;\nimport com.google.protobuf.InvalidProtocolBufferException;\nimport com.unitvectory.firestoreproto2map.FirestoreProto2Map;\nimport io.cloudevents.CloudEvent;\nimport java.util.logging.Logger;\n\npublic class FirebaseFirestore implements CloudEventsFunction {\n  private static final Logger logger = Logger.getLogger(FirebaseFirestore.class.getName());\n\n  @Override\n  public void accept(CloudEvent event) throws InvalidProtocolBufferException {\n    DocumentEventData firestoreEventData = DocumentEventData.parseFrom(event.getData().toBytes());\n    \n    // This will not handle DocumentReference attributes\n    FirestoreProto2Map firestoreProto2Map = new FirestoreProto2Map();\n\n    if (firestoreEventData.hasOldValue()) {\n      Map\u003cString, Object\u003e oldValueMap = firestoreProto2Map.convert(firestoreEventData.getOldValue());\n\n      // Map represents object that can be inserted into Firestore\n    }\n\n    if (firestoreEventData.hasValue()) {\n      Map\u003cString, Object\u003e valueMap = firestoreProto2Map.convert(firestoreEventData.getValue());\n\n      // Map represents object that can be inserted into Firestore\n    }\n  }\n}\n```\n\n## Reference Limitation\n\nFirestore supports reference documents, these are handled different from the other field types and require a `DocumentReference` object which requires the Firestore SDK to get that object.\n\n```java\nFirestore firestore  = FirestoreOptions.getDefaultInstance().getService();\n\n// This allows DocumentReference's to be handled\nFirestoreProto2Map converter = new FirestoreProto2Map(new ValueToDocumentReferenceMapper() {\n    @Override\n    public DocumentReference convert(String referenceValue, String documentPath) {\n        return firestore.document(documentPath);\n    }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funitvectory-labs%2Ffirestoreproto2map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funitvectory-labs%2Ffirestoreproto2map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funitvectory-labs%2Ffirestoreproto2map/lists"}