2017-10-24 14:43:45 +02:00
2017-10-24 12:16:46 +02:00
2017-10-21 12:30:56 +02:00
2017-10-24 12:26:54 +02:00
2017-10-21 12:30:56 +02:00
2017-10-24 14:43:45 +02:00

CodableFirebase

Use Codable with Firebase

Carthage compatible Build Status codecov

Overview

This library helps you to use your custom type that conform to Codable protocol with Firebase. Here's an example of model:

struct Model: Codable {
    let stringExample: String
    let booleanExample: Bool
    let numberExample: Double
    let dateExample: Date
    let arrayExample: [String]
    let nullExample: Int?
    let objectExample: [String: String]
}

And this is how you would encode it with Firebase Firestore:

import Firebase

let model: Model // here you will create an instance of Model
do {
    let docData = try FirestoreEncoder().encode(model)
    Firestore.firestore().collection("data").document("one").setData(docData) { err in
        if let err = err {
            print("Error writing document: \(err)")
        } else {
            print("Document successfully written!")
        }
    }
}
Description
No description provided
Readme MIT 162 KiB
Languages
Swift 98.5%
Ruby 1.1%
Objective-C 0.4%