ons-firestore 1.2.1 → 1.3.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: ffae582656edb80c22028523bd1b307e9878e20450ee25a2bba2924da506eb19
4
- data.tar.gz: cdbe8832c4f0a5d49fbf340530b8d1f3211ebf6bf50e49814b8e382ec7433224
3
+ metadata.gz: 4e6104269a49789359ba927ce1673d9e25b19afdd48caab6ae01f6ca4d99b757
4
+ data.tar.gz: 573ed986f15a3007c20d5196c67f590d34c260f68b0a3ff2314621eddf1e8a21
5
5
  SHA512:
6
- metadata.gz: fcbc120f1016150d54bff96aee74d5d2d772c807a7d17c6bb8da58f9728d899ef1ff543688c2b96229c1a87c63ff9fb5845100383f444a9970b1d71454378ce3
7
- data.tar.gz: 6f408ae0027ca9fc946acfc006081a5b018f837e0f8a5ada236d4d0f8aa826ef46fb2ed2bcdc712b960e6ea72a9fe22625d581968f95f6da5f4bc7b717609945
6
+ metadata.gz: 01cce206bdc4f36f909304aef53704b0d51e6f6ba7dcb77af2d6f90d8adb4773dcf38c11893555da99c2f2fa2aad7cb3001fb012c409d6a4f053a51d9efe8712
7
+ data.tar.gz: 6e85af05d6baa2d6b364c743cda54c2027dd717af567baafb0f3df1350fa70817b9ee011b50eb44a05cfee6a892a08356e22730634894b0b679b65de5886ce03
@@ -44,6 +44,24 @@ class Firestore
44
44
  @client.col(collection_name).doc(document_name)
45
45
  end
46
46
 
47
+ # Reads the +updated+ key within a Firestore document.
48
+ #
49
+ # @param collection_name [String] the name of the Firestore collection containing the document
50
+ # @param document_name [String] the name of the Firestore document
51
+ # @return [Object] document updated timestamp
52
+ # @raise [ArgumentError] if collection_name or document_name are nil
53
+ # @raise [FirestoreError] if the +updated+ key isn't present within the Firestore document
54
+ def document_updated(collection_name, document_name)
55
+ raise ArgumentError.new('collection_name cannot be nil') if collection_name.nil?
56
+ raise ArgumentError.new('document_name cannot be nil') if document_name.nil?
57
+
58
+ document = @client.col(collection_name).doc(document_name)
59
+ snapshot = document.get
60
+ raise FirestoreError, 'updated key is missing' if snapshot.updated.nil?
61
+
62
+ snapshot[:updated]
63
+ end
64
+
47
65
  # Reads the +data+ key within a Firestore document.
48
66
  #
49
67
  # @param collection_name [String] the name of the Firestore collection containing the document
@@ -3,8 +3,8 @@
3
3
  module ONSFirestore
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 2
7
- TINY = 1
6
+ MINOR = 3
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.2.1
4
+ version: 1.3.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-05-06 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-firestore
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.3.3
102
+ rubygems_version: 3.3.15
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Opinionated Google Firestore abstraction.