Skip to content

DavidSanf0rd/FireRecord-Android

Repository files navigation

FireRecord-Android

Download

FireRecord is a framework written in kotlin which brings the ActiveRecord architecture as a wrapper to Firebase SDK on Android. The main idea is to make Android developing with Firebase (Firestore and Storage) still more productive with the well-known Active Record Pattern from Rails community.

If you liked this library take a look at the iOS Swift version

Usage

Inherit from FireRecord

class User: FireRecord() {
  companion object: FireRecordCompanion<User>()

  var name: String? = null
  var age: Int? = null
  var birthDate: Date? = null
  @ServerTimestamp var createdAt: Date? = null
}

Init your model

val user = User()
user.name = "Jhon"
user.age = 19

Save

user.save { print("User saved on Firestore") }

Read

User.all { users ->
  users.forEach { print(it.name)}
}

User.load(id = "documentId") { user ->
  print(user.name)
}

Update

user.name = "My new Name"
user.update { print("updated user um Firestore") }

Delete

user.destroy { print("this user was deleted on Firestore") }

Features

  • Basic CRUD functionality with Firestore
  • Map queries from firestore
  • Manage image/file properties (send/retrieve from Storage)
  • Add realtime capabilities
  • Add offline capabilities

Requirements

Add Firebase to your project

Installation

Add Firestore and FireRecord to your app build.gradle

dependencies {
  // ...
  implementation 'com.google.firebase:firebase-core:11.8.0'
  implementation 'com.sanford.firerecord:firerecord:0.1'
}

License

FireRecord is available under the MIT license. See the LICENSE file for more info.

About

A Kotlin ActiveRecord-inspired model for Firebase/Firestore. Still in development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors