Swiftpack.co - 1amageek/DocumentID as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by 1amageek.
1amageek/DocumentID 0.2.0
FirebaseFirestoreSwift's library for lightweight use of DocumentIDs in SwiftUI.
⭐️ 8
🕓 1 year ago
iOS macOS watchOS
.package(url: "https://github.com/1amageek/DocumentID.git", from: "0.2.0")

DocumentID

The Firebase iOS SDK provides a Swift extension as FirebaseFirestoreSwift, and I created this library for the following reasons.

  1. The official library is too heavy for SwiftUI.
  2. optional ID of DocumentID is difficult to use.

In the Identifiable use case, it is unlikely that the ID will be nil. Also, the DocumentID of Firestore itself can never be nil. This is because the DocumentID in Firestore is provided as a random AutoID by the client.

In this library, DocumentID is not optional, and AutoID can be used to issue the same AutoID as Firebase. Also, by using it together with FirestoreSwift, you can use FirestoreEncoder and FirestoreDecoder in the same way as FirebaseFirestoreSwift.

Usage

public struct YourItem: Identifiable {

    @DocumentID public var id: String

    public var text: String

    public init(id: String = AutoID.generate(), text: String) {
        self.id = id
        self.text = text
    }
}

GitHub

link
Stars: 8
Last commit: 30 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics