There's a lot of open issues
ActiveRecord like interface for Firestore
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ActAsFireRecordBeta

  • Provides Rails applications with an ActiveRecord-like interface to manipulate Firestore.
  • Works as a wrapper for the google-cloud-firestore gem.

Installation

Add this line to your application's Gemfile:

gem "act_as_fire_record_beta"

And then execute:

$ bundle

Or install it yourself as:

$ gem install act_as_fire_record_beta

Overview

Model example:

class Book
  include ActAsFireRecordBeta

  firestore_attribute :title, :string
  firestore_attribute :published_on, :date
  firestore_attribute :page, :integer

  validates :title, presence: true

  before_validation :titleize_title

  private

  def titleize_title
    self.title = title.to_s.titleize
  end
end

CRUD example:

# Create
book = Book.new(title: 'An Awesome Book', published_on: '2022-12-01'.to_date, page: 200)
book.save
bool.id #=> IdG0ZWT0I5DucEQuRgoP

# Read
id = 'IdG0ZWT0I5DucEQuRgoP'
book = Book.find(id)

# Update
book.update(page: 210)

# Delete
book.destroy

Finder examples:

book = Book.find_by(title: 'An Awesome Book')

books = Book.all

books = Book.order(:title)
books = Book.order(:title, :desc)

books = Book.where(:page, :>=, 200)
books = Book.where(:page, :>=, 200).order(:page)

Please refer test codes for other APIs.

Setup, usage and etc.

As of now, Japanese document is only available.

README-ja.md

Google translate might help you.

Auto-translated README-ja.md

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.