act_as_fire_record_beta 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edeacaf31ef73ecb88185915a483712a188f66fc05c7ecdd54432ed4ceb2cfda
4
- data.tar.gz: 54937813b56125aa196af5c9b8abba535ba0abf95cc3eb2ee32ad677fe8b8d12
3
+ metadata.gz: c76e43b19f1342e88e1b20294590913587ac006c208181fa517c99f1023f1d00
4
+ data.tar.gz: 14f4ae4b3496befa9569837c0fa99fa902eb4b12d9c720a73ecf846913ef5ad1
5
5
  SHA512:
6
- metadata.gz: d1b0f6e6bc7bdc58db9488d273634e8a6f417c3222d3a1c900ffb4caedbe690b7f41907e7487a581d4ec9087da2c787ceb9b08a9f12fa90928763de06ab72174
7
- data.tar.gz: 29be871e1061cc0e426fbd54877c640db94e549577f7f2a281c48b9315a321fa6f62f20dec1116c97dd651386e121ce0dd0a79901881300fbd1544a940575d57
6
+ metadata.gz: 888b6e53584137db8793d626f8afd323474cd27473179a95c5253280cbf1ad21ecca33bd166f404821303a98aa6c8b69c4ac49f245e3e4e994d43a1dbbb55342
7
+ data.tar.gz: 9c0716e6bb104a0a526cd1e56229031a4f472c1ef1b0352a29e7e5e1126ff0b9af7720f09796c704b8f82aac2258d0822c98b45ae842dc31eade33c2a97c8509
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # ActAsFireRecordBeta
2
- Short description and motivation.
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ - Provides Rails applications with an ActiveRecord-like interface to manipulate Firestore.
4
+ - Works as a wrapper for the [google-cloud-firestore](https://rubygems.org/gems/google-cloud-firestore) gem.
6
5
 
7
6
  ## Installation
8
7
  Add this line to your application's Gemfile:
@@ -21,6 +20,74 @@ Or install it yourself as:
21
20
  $ gem install act_as_fire_record_beta
22
21
  ```
23
22
 
23
+ ## Overview
24
+
25
+ Model example:
26
+
27
+ ```ruby
28
+ class Book
29
+ include ActAsFireRecordBeta
30
+
31
+ firestore_attribute :title, :string
32
+ firestore_attribute :published_on, :date
33
+ firestore_attribute :page, :integer
34
+
35
+ validates :title, presence: true
36
+
37
+ before_validation :titleize_title
38
+
39
+ private
40
+
41
+ def titleize_title
42
+ self.title = title.to_s.titleize
43
+ end
44
+ end
45
+ ```
46
+
47
+ CRUD example:
48
+
49
+ ```ruby
50
+ # Create
51
+ book = Book.new(title: 'An Awesome Book', published_on: '2022-12-01'.to_date, page: 200)
52
+ book.save
53
+ bool.id #=> IdG0ZWT0I5DucEQuRgoP
54
+
55
+ # Read
56
+ id = 'IdG0ZWT0I5DucEQuRgoP'
57
+ book = Book.find(id)
58
+
59
+ # Update
60
+ book.update(page: 210)
61
+
62
+ # Delete
63
+ book.destroy
64
+ ```
65
+
66
+ Finder examples:
67
+
68
+ ```ruby
69
+ book = Book.find_by(title: 'An Awesome Book')
70
+
71
+ books = Book.all.get_records
72
+
73
+ books = Book.order(:title).get_records
74
+ books = Book.order(:title, :desc).get_records
75
+
76
+ books = Book.where(:page, :>=, 200).get_records
77
+ books = Book.where(:page, :>=, 200).order(:page).get_records
78
+ ```
79
+
80
+ Please refer test codes for other APIs.
81
+
82
+ - https://github.com/JunichiIto/act_as_fire_record_beta/blob/main/test/act_as_fire_record_beta_test.rb
83
+ - https://github.com/JunichiIto/act_as_fire_record_beta/blob/main/test/google/cloud/firestore/query_test.rb
84
+
85
+ ## Setup, usage and etc.
86
+
87
+ As of now, Japanese document is only available.
88
+
89
+ [README-ja.md](https://github.com/JunichiIto/act_as_fire_record_beta/blob/main/README-ja.md)
90
+
24
91
  ## Contributing
25
92
  Contribution directions go here.
26
93
 
@@ -1,3 +1,3 @@
1
1
  module ActAsFireRecordBeta
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -48,15 +48,12 @@ module ActAsFireRecordBeta
48
48
  def col
49
49
  @_col ||= client.col(collection_name_with_env)
50
50
  end
51
+ alias all col
51
52
 
52
53
  def doc(id)
53
54
  client.doc("#{collection_name_with_env}/#{id}")
54
55
  end
55
56
 
56
- def all
57
- col.get_records
58
- end
59
-
60
57
  def find(id)
61
58
  data = doc(id).get
62
59
  raise ActAsFireRecordBeta::RecordNotFound, "Couldn't find record with #{self} with 'id'='#{id}'" if data.missing?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: act_as_fire_record_beta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junichi Ito