quickbase_record 0.4.2 → 0.4.3
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 +8 -8
- data/README.md +24 -4
- data/lib/quickbase_record/queries.rb +11 -0
- data/lib/quickbase_record/version.rb +1 -1
- data/spec/queries_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTQ2NTM5YWQxZTkwNDhiODdjODk5YTBjNTBmNmUxN2JmNzUyYzk1ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjA2MmViOGQ1OWU5ZDBmZDI5YWUxNTU3ZDU0YWY3YWYwMTc0ZjExNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTE2MjU2NDNiNDU0ODVhMGEzYWNjMDBiYjE1M2QxZjk4MTExYTVmMWI5YzI0
|
10
|
+
NzE2ZTYwMzYxYWZhNDg1ZjBjZWI4OWRhYTE2MjcwZWMwZTFkODFhZWNkNzNj
|
11
|
+
ZGVlMWRjODQxY2ZkNTM3MTYxNTVlMWViZWZlNjRlZTVhNjRkMDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDA5ZDEyMGRlMjE5MDVmNzk3OTZhOWI3N2YwNjVjZDNmODg5OGNjODRmNDIx
|
14
|
+
OGMxODg3ZTM0MWEwOTA0NjNjM2JjYmY0NTk2YzQ2YTg2NGI5NWU0NWVhMGVj
|
15
|
+
YWMwYzM0YzhkOTZjNzlhYzVjOTJlYjEyMGYyY2M0ZjU1ODg1NzQ=
|
data/README.md
CHANGED
@@ -103,6 +103,14 @@ Post.build_query(author: 'Cullen', title: 'Some Title')
|
|
103
103
|
=> "{'8'.EX.'Cullen'}AND{'9'.EX.'Some Title'}"
|
104
104
|
```
|
105
105
|
|
106
|
+
You can also access the underlying instance of the AdvantageQuickbase client with .qb_client. This property lives on both the class and on any instance of that class. To access the dbid for the table, call .dbid on the class.
|
107
|
+
|
108
|
+
```
|
109
|
+
Post.qb_client.do_query(...)
|
110
|
+
@post = Post.new(...)
|
111
|
+
@post.qb_client.edit_record(self.class.dbid, self.id, {5 => 'Something', 6 => 'Something else'})
|
112
|
+
```
|
113
|
+
|
106
114
|
## Available Methods
|
107
115
|
* **.create(attributes_hash)**
|
108
116
|
- Intantiate *and* save a new object with the given attributes
|
@@ -129,7 +137,7 @@ Post.build_query(author: 'Cullen', title: 'Some Title')
|
|
129
137
|
Post.find(params[:id])
|
130
138
|
```
|
131
139
|
|
132
|
-
* **.where(attributes_hash)**
|
140
|
+
* **.where(attributes_hash OR string)**
|
133
141
|
- Query QuickBase by any field name defined in your class' field mapping
|
134
142
|
- Returns an array of objects
|
135
143
|
```
|
@@ -160,7 +168,7 @@ Post.build_query(author: 'Cullen', title: 'Some Title')
|
|
160
168
|
- Combine arrays and hashes to build more complex queries
|
161
169
|
```
|
162
170
|
Post.where(id: [{XEX: 123}, {OBF: 'today'}])
|
163
|
-
# "{'3'.XEX.'123'}OR{'3'.
|
171
|
+
# "{'3'.XEX.'123'}OR{'3'.OBF.'today'}"
|
164
172
|
|
165
173
|
Post.where(id: {XEX: 123, OAF: 'today'})
|
166
174
|
# "{'3'.XEX.'123'}AND{'3'.OAF.'today'}"
|
@@ -173,9 +181,9 @@ Post.build_query(author: 'Cullen', title: 'Some Title')
|
|
173
181
|
Post.where("{author.XEX.'Cullen Jett'}")
|
174
182
|
```
|
175
183
|
|
176
|
-
|
184
|
+
* **Query Options (clist, slist, options)** To query using the QuickBase query options such as 'clist', 'slist', or 'options', include :query_options as a hash of option_property: value
|
177
185
|
```
|
178
|
-
Post.where(author: ['Cullen Jett', 'Socrates'], query_options: {clist: 'id.author', slist: 'author'})
|
186
|
+
Post.where(author: ['Cullen Jett', 'Socrates'], query_options: {clist: 'id.author', slist: 'author', options: 'num-1'})
|
179
187
|
```
|
180
188
|
|
181
189
|
* **.batch_where(attributes_hash, count=1000)**
|
@@ -210,6 +218,18 @@ Post.build_query(author: 'Cullen', title: 'Some Title')
|
|
210
218
|
@post.delete
|
211
219
|
```
|
212
220
|
|
221
|
+
* **.purge_records(attributes_hash OR QID)**
|
222
|
+
- Delete ALL records that match the attributes hash or are in the record corresponding to the QID argument
|
223
|
+
- Returns an array of deleted rids
|
224
|
+
- **CAUTION** If you do not supply a query parameter, this call will delete ALL of the records in the table.
|
225
|
+
```
|
226
|
+
Post.purge_records(name: 'Cullen Jett') # attributes hash
|
227
|
+
or
|
228
|
+
Post.purge_records(9) # QID
|
229
|
+
|
230
|
+
=> [1,2,3,4,5...]
|
231
|
+
```
|
232
|
+
|
213
233
|
* **#update_attributes(attributes_hash)**
|
214
234
|
- **IMPORTANT: Updates *and* saves the object with the new attributes**
|
215
235
|
- Only sends the passed in attributes as arguments to API_AddRecord or API_EditRecord (depending on whether the object has an ID or not)
|
@@ -85,6 +85,17 @@ module QuickbaseRecord
|
|
85
85
|
all_query_results.flatten
|
86
86
|
end
|
87
87
|
|
88
|
+
def purge_records(query_hash)
|
89
|
+
query = {}
|
90
|
+
if query_hash.is_a? Numeric
|
91
|
+
query[:qid] = query_hash
|
92
|
+
else
|
93
|
+
query[:query] = build_query(query_hash)
|
94
|
+
end
|
95
|
+
|
96
|
+
query_response = qb_client.purge_records(dbid, query)
|
97
|
+
end
|
98
|
+
|
88
99
|
def build_quickbase_request(object)
|
89
100
|
converted_object = {}
|
90
101
|
fields.each do |field_name, field|
|
data/spec/queries_spec.rb
CHANGED
@@ -97,6 +97,21 @@ RSpec.describe QuickbaseRecord::Queries do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
describe '.purge_records' do
|
101
|
+
it "deletes all matching query records" do
|
102
|
+
teacher1 = TeacherFake.create(name: 'I should be deleted')
|
103
|
+
TeacherFake.purge_records(name: teacher1.name)
|
104
|
+
expect(TeacherFake.find(teacher1.id)).to be_nil
|
105
|
+
end
|
106
|
+
|
107
|
+
it "accepts a QID" do
|
108
|
+
teacher1 = TeacherFake.create(name: 'Purge McSplurge')
|
109
|
+
expect(TeacherFake.qid(5).length).to eq(1)
|
110
|
+
TeacherFake.purge_records(5)
|
111
|
+
expect(TeacherFake.qid(5)).to eq([])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
100
115
|
describe '#save' do
|
101
116
|
it "doesn't save :read_only fields" do
|
102
117
|
classroom = ClassroomFake.find(101)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbase_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cullen Jett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|