Skip to content

Commit 0dac13f

Browse files
Finishing touches
1 parent 59e6ee7 commit 0dac13f

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,24 @@ client.objects.update(
114114
)
115115

116116
# Batch create objects
117-
client.objects.batch_create(objects: [
117+
response = client.objects.batch_create(objects: [
118118
{
119-
class_name: "Question",
119+
class: "Question",
120120
properties: {
121121
answer: "42",
122122
question: "What is the meaning of life?",
123123
category: "philosophy"
124124
}
125125
}, {
126-
class_name: "Question",
126+
class: "Question",
127127
properties: {
128128
answer: "42",
129129
question: "What does 6 times 7 equal to?",
130130
category: "math"
131131
}
132132
}
133133
])
134+
response.data
134135
```
135136

136137
## Development

lib/weaviate/objects.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def batch_create(objects:)
5050
response = client.connection.post("batch/#{PATH}") do |req|
5151
req.body = {objects: objects}
5252
end
53-
Response::Collection.from_response(response, key: "objects", type: Response::Object)
53+
54+
if response.success?
55+
Response::Collection.from_response(response, type: Response::Object)
56+
end
5457
end
5558

5659
# Get a single data object.

spec/fixtures/objects.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
{
2-
"objects": [
3-
{
4-
"class": "Question",
5-
"creationTimeUnix": 1679757150769,
6-
"id": "123",
7-
"lastUpdateTimeUnix": 1679757150769,
8-
"properties": {
9-
"answer": "42",
10-
"category": "philosophy",
11-
"question": "What is the meaning of life?"
12-
}
1+
[
2+
{
3+
"class": "Question",
4+
"creationTimeUnix": 1679757150769,
5+
"id": "123",
6+
"lastUpdateTimeUnix": 1679757150769,
7+
"properties": {
8+
"answer": "42",
9+
"category": "philosophy",
10+
"question": "What is the meaning of life?"
1311
}
14-
],
15-
"totalResults": 1
16-
}
12+
}
13+
]

spec/weaviate/objects_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
end
3838

3939
describe "#list" do
40-
let(:response) { OpenStruct.new(body: objects_fixture) }
40+
let(:response) { OpenStruct.new(body: {"objects" => objects_fixture}) }
4141

4242
before do
4343
allow_any_instance_of(Faraday::Connection).to receive(:get)

0 commit comments

Comments
 (0)