airtable2 0.2.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/airtable/base.rb +1 -1
- data/lib/airtable/table.rb +13 -0
- data/lib/airtable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1badb986f7b3fabd00b1311e03f91e95b16888ce75ebe31477b125975e5ae4b
|
4
|
+
data.tar.gz: d734810a0765508d23831fd5f777afcdf3f30df10fcdb27e240bc00c47c95292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9e84cfbbc55b179fa9747d7ee27716ea517c9d3a7303f1eb2b59fe66817d6072b9cbc4beed3abdbd145f9f47ddf6ce59d53ae130e94c40e234240b451f501a
|
7
|
+
data.tar.gz: f966f605482ad29b80c83199dfc7e63085b16a847e5cb0df649de6e381aa983c94949f2d4c7ce1d19d3e7cd1e0b3ece316d7b83ddc95768c6e54bd4c14f543c8
|
data/README.md
CHANGED
@@ -108,6 +108,14 @@ A single record or an array of records can be inserted using the `create_records
|
|
108
108
|
@table.create_records([{ 'Name': 'name value', 'Age': 35 }, { 'Name': 'another name value', 'Age': 40 }])
|
109
109
|
```
|
110
110
|
|
111
|
+
You can upsert records by calling `upsert_records` and providing the field names to match to (also max 10 at a time):
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
# Array
|
115
|
+
records_to_upsert = [{ 'Name': 'name value', 'Age': 35 }, { 'Name': 'another name value', 'Age': 40 }]
|
116
|
+
@table.upsert_records(records_to_upsert, ['Name'])
|
117
|
+
```
|
118
|
+
|
111
119
|
A single record or an array of records can be destroyed by passing their ids to the `delete_records` method on a table (max 10 at a time):
|
112
120
|
|
113
121
|
```ruby
|
data/lib/airtable/base.rb
CHANGED
data/lib/airtable/table.rb
CHANGED
@@ -71,6 +71,19 @@ class Airtable::Table < Airtable::Resource
|
|
71
71
|
response['records'].map { Airtable::Record.new(@token, self, _1['id'], _1) }
|
72
72
|
end
|
73
73
|
|
74
|
+
# @param [Array] Record objects to upsert
|
75
|
+
# @return [Array<Airtable::Record>]
|
76
|
+
# @see https://airtable.com/developers/web/api/update-multiple-records
|
77
|
+
# @note API maximum of 10 records at a time
|
78
|
+
def upsert_records(records, fields_to_merge_on)
|
79
|
+
response = self.class.patch(table_url,
|
80
|
+
body: { performUpsert: { fieldsToMergeOn: fields_to_merge_on }, records: Array(records).map { |fields| { fields: } } }.to_json).parsed_response
|
81
|
+
|
82
|
+
check_and_raise_error(response)
|
83
|
+
|
84
|
+
response['records'].map { Airtable::Record.new(@token, self, _1['id'], _1) }
|
85
|
+
end
|
86
|
+
|
74
87
|
# @param [Array] IDs of records to delete
|
75
88
|
# @return [Array] Deleted record ids
|
76
89
|
# @see https://airtable.com/developers/web/api/delete-multiple-records
|
data/lib/airtable/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airtable2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Seroff
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|