ons-firestore 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f758241e0412f8c0b4c72776352c753dd44cea5bcca617bd80efb90baa12829
4
- data.tar.gz: ada12ed5b8d5d1d4ece7cf7812d839dba8f6e55fe592e7ac97e6d00a443565ef
3
+ metadata.gz: '0077852086ffe77e35e89820a68feae7bc2711f74f0727dca47587344c8d0a41'
4
+ data.tar.gz: 3fa7333f538ac6f6ed5038d8c6190a02473c7f451ca2dfe04b4e5d151ec27ceb
5
5
  SHA512:
6
- metadata.gz: 0f7c7171137c9bc2c6dc8ddf9b96f2ece25c77c3a7cb17031f9a763ac0fea9b41bc797bc3612f884cb5f30513b8a84b01ec69fbe16f9621e9df557e7c7b854fb
7
- data.tar.gz: e37cf44ff5a87a260d98f045a04624eaac0cb441ac910472538d2f36716cab74ea3ad0484511901f2ad688a0a2f703a3f068914939334250250ff4aa6e9e9c15
6
+ metadata.gz: f01fb9331db325667ac3e60f6e1a9310f05cc3fdd0025462913bfc5c328191fefc1deb5b2de921aacb48377ade65cb090af4ac622b493b14c5a8df49d74bcedf
7
+ data.tar.gz: cf2ca0fb7c3fd1093c56d12388174e726133d1e8df59fe8da319d97e18d1cd089c6aaba7e31ed8eee17591d960aaa7f84bdd16f9825106c3de8a69dee80791cb
@@ -10,10 +10,8 @@ class Firestore
10
10
 
11
11
  # Constructor that initialises the Firestore client.
12
12
  #
13
- # Params:
14
- # - project_id: The ID of the GCP project containing the Firestore database.
15
- #
16
- # An Argument error is raised if project_id is nil.
13
+ # @param project_id [String] the ID of the GCP project containing the Firestore database
14
+ # @raise [ArgumentError] if project_id is nil
17
15
  def initialize(project_id)
18
16
  raise ArgumentError.new('project_id cannot be nil') if project_id.nil?
19
17
 
@@ -21,13 +19,36 @@ class Firestore
21
19
  @client = Google::Cloud::Firestore.new
22
20
  end
23
21
 
24
- # Reads a Firestore document.
22
+ # Returns all Firestore documents within a collection.
23
+ #
24
+ # @param collection_name [String] the name of the Firestore collection containing the documents
25
+ # @return [Enumberator] list of documents within the collection
26
+ # @raise [ArgumentError] if collection_name is nil
27
+ def all_documents(collection_name)
28
+ raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
29
+
30
+ @client.col(collection_name).list_documents.all
31
+ end
32
+
33
+ # Returns a reference to a Firestore document.
25
34
  #
26
- # Params:
27
- # - collection_name: The name of the Firestore collection containing the document.
28
- # - document_name: The name of the Firestore document.
35
+ # @param collection_name [String] the name of the Firestore collection containing the document
36
+ # @param document_name [String] the name of the Firestore document
37
+ # @return [Google::Cloud::Firestore::DocumentReference] reference to the document
38
+ # @raise [ArgumentError] if collection_name or document_name are nil
39
+ def document_reference(collection_name, document_name)
40
+ raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
41
+ raise ArgumentError.new('document_name cannot be nil') if document_name.nil?
42
+
43
+ @client.col(collection_name).doc(document_name)
44
+ end
45
+
46
+ # Reads the +data+ key within a Firestore document.
29
47
  #
30
- # An Argument error is raised if collection_name or document_name are nil.
48
+ # @param collection_name [String] the name of the Firestore collection containing the document
49
+ # @param document_name [String] the name of the Firestore document
50
+ # @return [Object] document data
51
+ # @raise [ArgumentError] if collection_name or document_name are nil
31
52
  def read_document(collection_name, document_name)
32
53
  raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
33
54
  raise ArgumentError.new('document_name cannot be nil') if document_name.nil?
@@ -42,12 +63,10 @@ class Firestore
42
63
  # The passed data are saved under a +data+ key within the document.
43
64
  # A timestamp at which the operation occurred is saved under the +updated+ key within the document.
44
65
  #
45
- # Params:
46
- # - collection_name: The name of the Firestore collection containing the document.
47
- # - document_name: The name of the Firestore document.
48
- # - data: Data to save to the Firestore document.
49
- #
50
- # An Argument error is raised if collection_name or document_name are nil.
66
+ # @param collection_name [String] the name of the Firestore collection containing the document
67
+ # @param document_name [String] the name of the Firestore document
68
+ # @param data [Object] data to save to the Firestore document
69
+ # @raise [ArgumentError] if collection_name or document_name are nil
51
70
  def save_document(collection_name, document_name, data)
52
71
  raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
53
72
  raise ArgumentError.new('document_name cannot be nil') if document_name.nil?
@@ -3,8 +3,8 @@
3
3
  module ONSFirestore
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 0
7
- TINY = 2
6
+ MINOR = 1
7
+ TINY = 0
8
8
  end
9
9
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].compact * '.'
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ons-firestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Topley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-27 00:00:00.000000000 Z
11
+ date: 2022-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-firestore