You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it("tears down and cleans up",()=>cleanup(client));
242
244
});
243
245
246
+
describe("batch deleting",()=>{
247
+
constclient=weaviate.client({
248
+
scheme: "http",
249
+
host: "localhost:8080",
250
+
});
251
+
252
+
it("sets up schema",()=>setup(client));
253
+
it("sets up data",()=>setupData(client));
254
+
255
+
it("batch deletes with dryRun and verbose output",()=>
256
+
client.batch
257
+
.objectsBatchDeleter()
258
+
.withClassName(thingClassName)
259
+
.withWhere({
260
+
operator: Operator.EQUAL,
261
+
valueString: "bar1",
262
+
path: ["stringProp"]
263
+
})
264
+
.withDryRun(true)
265
+
.withOutput(Output.VERBOSE)
266
+
.do()
267
+
.then(result=>{
268
+
expect(result.dryRun).toBe(true);
269
+
expect(result.output).toBe(Output.VERBOSE);
270
+
expect(result.match).toEqual({
271
+
class: thingClassName,
272
+
where: {
273
+
operands: null,// FIXME should not be received
274
+
operator: Operator.EQUAL,
275
+
valueString: "bar1",
276
+
path: ["stringProp"],
277
+
},
278
+
})
279
+
expect(result.results).toEqual({
280
+
successful: 0,
281
+
failed: 0,
282
+
matches: 1,
283
+
limit: 10000,
284
+
objects: [{
285
+
id: thingIds[1],
286
+
status: Status.DRYRUN,
287
+
}],
288
+
});
289
+
})
290
+
)
291
+
292
+
it("batch deletes with dryRun and minimal output",()=>
293
+
client.batch
294
+
.objectsBatchDeleter()
295
+
.withClassName(otherThingClassName)
296
+
.withWhere({
297
+
operator: Operator.LIKE,
298
+
valueString: "foo3",
299
+
path: ["stringProp"]
300
+
})
301
+
.withDryRun(true)
302
+
.withOutput(Output.MINIMAL)
303
+
.do()
304
+
.then(result=>{
305
+
expect(result.dryRun).toBe(true);
306
+
expect(result.output).toBe(Output.MINIMAL);
307
+
expect(result.match).toEqual({
308
+
class: otherThingClassName,
309
+
where: {
310
+
operands: null,// FIXME should not be received
311
+
operator: Operator.LIKE,
312
+
valueString: "foo3",
313
+
path: ["stringProp"],
314
+
},
315
+
})
316
+
expect(result.results).toEqual({
317
+
successful: 0,
318
+
failed: 0,
319
+
matches: 1,
320
+
limit: 10000,
321
+
objects: null,
322
+
});
323
+
})
324
+
)
325
+
326
+
it("batch deletes but no matches with default dryRun and output",()=>
327
+
client.batch
328
+
.objectsBatchDeleter()
329
+
.withClassName(otherThingClassName)
330
+
.withWhere({
331
+
operator: Operator.EQUAL,
332
+
valueString: "doesNotExist",
333
+
path: ["stringProp"]
334
+
})
335
+
.do()
336
+
.then(result=>{
337
+
expect(result.dryRun).toBe(false);
338
+
expect(result.output).toBe(Output.MINIMAL);
339
+
expect(result.match).toEqual({
340
+
class: otherThingClassName,
341
+
where: {
342
+
operands: null,// FIXME should not be received
343
+
operator: Operator.EQUAL,
344
+
valueString: "doesNotExist",
345
+
path: ["stringProp"],
346
+
},
347
+
})
348
+
expect(result.results).toEqual({
349
+
successful: 0,
350
+
failed: 0,
351
+
matches: 0,
352
+
limit: 10000,
353
+
objects: null,
354
+
});
355
+
})
356
+
)
357
+
358
+
it("batch deletes with default dryRun",()=>{
359
+
constinAMinute=""+(newDate().getTime()+60*1000);
360
+
returnclient.batch
361
+
.objectsBatchDeleter()
362
+
.withClassName(otherThingClassName)
363
+
.withWhere({
364
+
operator: Operator.LESS_THAN,
365
+
valueString: inAMinute,
366
+
path: ["_creationTimeUnix"]
367
+
})
368
+
.withOutput(Output.VERBOSE)
369
+
.do()
370
+
.then(result=>{
371
+
expect(result.dryRun).toBe(false);
372
+
expect(result.output).toBe(Output.VERBOSE);
373
+
expect(result.match).toEqual({
374
+
class: otherThingClassName,
375
+
where: {
376
+
operands: null,// FIXME should not be received
377
+
operator: Operator.LESS_THAN,
378
+
valueString: inAMinute,
379
+
path: ["_creationTimeUnix"],
380
+
},
381
+
})
382
+
expect(result.results.successful).toBe(2);
383
+
expect(result.results.failed).toBe(0);
384
+
expect(result.results.matches).toBe(2);
385
+
expect(result.results.limit).toBe(10000);
386
+
expect(result.results.objects).toHaveLength(2)
387
+
expect(result.results.objects).toContainEqual({
388
+
id: otherThingIds[0],
389
+
status: Status.SUCCESS,
390
+
});
391
+
expect(result.results.objects).toContainEqual({
392
+
id: otherThingIds[1],
393
+
status: Status.SUCCESS,
394
+
});
395
+
})
396
+
})
397
+
398
+
it("batch deletes fails due to validation",()=>
399
+
client.batch
400
+
.objectsBatchDeleter()
401
+
.withClassName("")
402
+
.withWhere("shouldBeObject")
403
+
.do()
404
+
.catch(err=>expect(err.toString()).toBe("Error: invalid usage: string className must be set - set with .withClassName(className), object where must be set - set with .withWhere(whereFilter)"))
405
+
)
406
+
407
+
it("tears down and cleans up",()=>cleanup(client));
0 commit comments