meadow 2.0.23 → 2.0.27

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.
Files changed (62) hide show
  1. package/README.md +110 -141
  2. package/docs/README.md +34 -230
  3. package/docs/_cover.md +14 -0
  4. package/docs/_sidebar.md +44 -12
  5. package/docs/_topbar.md +5 -0
  6. package/docs/api/doCount.md +109 -0
  7. package/docs/api/doCreate.md +132 -0
  8. package/docs/api/doDelete.md +101 -0
  9. package/docs/api/doRead.md +122 -0
  10. package/docs/api/doReads.md +136 -0
  11. package/docs/api/doUndelete.md +98 -0
  12. package/docs/api/doUpdate.md +129 -0
  13. package/docs/api/getRoleName.md +84 -0
  14. package/docs/api/loadFromPackage.md +153 -0
  15. package/docs/api/marshalRecordFromSourceToObject.md +92 -0
  16. package/docs/api/query.md +133 -0
  17. package/docs/api/rawQueries.md +197 -0
  18. package/docs/api/reference.md +117 -0
  19. package/docs/api/setAuthorizer.md +103 -0
  20. package/docs/api/setDefault.md +90 -0
  21. package/docs/api/setDefaultIdentifier.md +84 -0
  22. package/docs/api/setDomain.md +56 -0
  23. package/docs/api/setIDUser.md +91 -0
  24. package/docs/api/setJsonSchema.md +92 -0
  25. package/docs/api/setProvider.md +87 -0
  26. package/docs/api/setSchema.md +107 -0
  27. package/docs/api/setScope.md +68 -0
  28. package/docs/api/validateObject.md +119 -0
  29. package/docs/architecture.md +316 -0
  30. package/docs/audit-tracking.md +226 -0
  31. package/docs/configuration.md +317 -0
  32. package/docs/providers/meadow-endpoints.md +306 -0
  33. package/docs/providers/mongodb.md +319 -0
  34. package/docs/providers/postgresql.md +312 -0
  35. package/docs/providers/rocksdb.md +297 -0
  36. package/docs/query-dsl.md +269 -0
  37. package/docs/quick-start.md +384 -0
  38. package/docs/raw-queries.md +193 -0
  39. package/docs/retold-catalog.json +61 -1
  40. package/docs/retold-keyword-index.json +15860 -4839
  41. package/docs/soft-deletes.md +224 -0
  42. package/package.json +44 -13
  43. package/scripts/bookstore-seed-postgresql.sql +135 -0
  44. package/scripts/dgraph-test-db.sh +144 -0
  45. package/scripts/meadow-test-cleanup.sh +5 -1
  46. package/scripts/mongodb-test-db.sh +98 -0
  47. package/scripts/postgresql-test-db.sh +124 -0
  48. package/scripts/solr-test-db.sh +135 -0
  49. package/source/Meadow.js +5 -0
  50. package/source/providers/Meadow-Provider-DGraph.js +679 -0
  51. package/source/providers/Meadow-Provider-MeadowEndpoints.js +1 -1
  52. package/source/providers/Meadow-Provider-MongoDB.js +527 -0
  53. package/source/providers/Meadow-Provider-PostgreSQL.js +361 -0
  54. package/source/providers/Meadow-Provider-RocksDB.js +1300 -0
  55. package/source/providers/Meadow-Provider-Solr.js +726 -0
  56. package/test/Meadow-Provider-DGraph_tests.js +741 -0
  57. package/test/Meadow-Provider-MongoDB_tests.js +661 -0
  58. package/test/Meadow-Provider-PostgreSQL_tests.js +787 -0
  59. package/test/Meadow-Provider-RocksDB_tests.js +887 -0
  60. package/test/Meadow-Provider-SQLiteBrowser-Headless_tests.js +657 -0
  61. package/test/Meadow-Provider-SQLiteBrowser_tests.js +895 -0
  62. package/test/Meadow-Provider-Solr_tests.js +679 -0
@@ -0,0 +1,679 @@
1
+ /**
2
+ * Unit tests for the Meadow "Solr" Provider
3
+ *
4
+ * These tests expect a Solr instance.....
5
+ *
6
+ * @license MIT
7
+ *
8
+ * @author Steven Velozo <steven@velozo.com>
9
+ */
10
+
11
+ var Chai = require("chai");
12
+ var Expect = Chai.expect;
13
+
14
+ const libMeadowConnectionSolr = require('meadow-connection-solr');
15
+
16
+ var tmpFableSettings = (
17
+ {
18
+ "Product": "MeadowSolrTestBookstore",
19
+ "ProductVersion": "1.0.0",
20
+
21
+ "UUID":
22
+ {
23
+ "DataCenter": 0,
24
+ "Worker": 0
25
+ },
26
+ "LogStreams":
27
+ [
28
+ {
29
+ "streamtype": "console"
30
+ }
31
+ ],
32
+
33
+ "Solr":
34
+ {
35
+ "Server": "127.0.0.1",
36
+ "Port": 38983,
37
+ "Core": "meadow_test"
38
+ }
39
+ });
40
+
41
+ var libFable = new (require('fable'))(tmpFableSettings);
42
+
43
+ libFable.serviceManager.addServiceType('MeadowSolrProvider', libMeadowConnectionSolr);
44
+ libFable.serviceManager.instantiateServiceProvider('MeadowSolrProvider');
45
+
46
+ var _AnimalJsonSchema = (
47
+ {
48
+ title: "Animal",
49
+ description: "A creature that lives in a meadow.",
50
+ type: "object",
51
+ properties: {
52
+ IDAnimal: {
53
+ description: "The unique identifier for an animal",
54
+ type: "integer"
55
+ },
56
+ Name: {
57
+ description: "The animal's name",
58
+ type: "string"
59
+ },
60
+ Type: {
61
+ description: "The type of the animal",
62
+ type: "string"
63
+ }
64
+ },
65
+ required: ["IDAnimal", "Name", "CreatingIDUser"]
66
+ });
67
+ var _AnimalSchema = (
68
+ [
69
+ { Column: "IDAnimal", Type: "AutoIdentity" },
70
+ { Column: "GUIDAnimal", Type: "AutoGUID" },
71
+ { Column: "CreateDate", Type: "CreateDate" },
72
+ { Column: "CreatingIDUser", Type: "CreateIDUser" },
73
+ { Column: "UpdateDate", Type: "UpdateDate" },
74
+ { Column: "UpdatingIDUser", Type: "UpdateIDUser" },
75
+ { Column: "Deleted", Type: "Deleted" },
76
+ { Column: "DeletingIDUser", Type: "DeleteIDUser" },
77
+ { Column: "DeleteDate", Type: "DeleteDate" },
78
+ { Column: "Name", Type: "String" },
79
+ { Column: "Type", Type: "String" }
80
+ ]);
81
+ var _AnimalDefault = (
82
+ {
83
+ IDAnimal: null,
84
+ GUIDAnimal: '',
85
+
86
+ CreateDate: false,
87
+ CreatingIDUser: 0,
88
+ UpdateDate: false,
89
+ UpdatingIDUser: 0,
90
+ Deleted: 0,
91
+ DeleteDate: false,
92
+ DeletingIDUser: 0,
93
+
94
+ Name: 'Unknown',
95
+ Type: 'Unclassified'
96
+ });
97
+
98
+ suite
99
+ (
100
+ 'Meadow-Provider-Solr',
101
+ function ()
102
+ {
103
+ var _SpooledUp = false;
104
+
105
+ var newMeadow = function ()
106
+ {
107
+ return require('../source/Meadow.js')
108
+ .new(libFable, 'FableTest')
109
+ .setProvider('Solr')
110
+ .setSchema(_AnimalSchema)
111
+ .setJsonSchema(_AnimalJsonSchema)
112
+ .setDefaultIdentifier('IDAnimal')
113
+ .setDefault(_AnimalDefault)
114
+ };
115
+
116
+ suiteSetup
117
+ (
118
+ function (fDone)
119
+ {
120
+ this.timeout(30000);
121
+ if (!_SpooledUp)
122
+ {
123
+ libFable.MeadowSolrProvider.connectAsync(
124
+ (pError) =>
125
+ {
126
+ if (pError)
127
+ {
128
+ libFable.log.error(`Error connecting to Solr: ${pError}`);
129
+ return fDone(pError);
130
+ }
131
+
132
+ var tmpClient = libFable.MeadowSolrProvider.pool;
133
+
134
+ // Delete all existing documents
135
+ tmpClient.deleteByQuery('*:*', function (pDeleteError)
136
+ {
137
+ if (pDeleteError)
138
+ {
139
+ return fDone(pDeleteError);
140
+ }
141
+ tmpClient.commit(function (pCommitError)
142
+ {
143
+ if (pCommitError)
144
+ {
145
+ return fDone(pCommitError);
146
+ }
147
+
148
+ var tmpNow = new Date().toISOString();
149
+
150
+ // Seed the counter document
151
+ var tmpCounterDoc = { id: 'FableTest.IDAnimal', seq: 5 };
152
+
153
+ // Seed 5 animals + counter
154
+ var tmpDocs = [
155
+ tmpCounterDoc,
156
+ { id: 'FableTest-1', IDAnimal: 1, GUIDAnimal: '00000000-0000-0000-0000-000000000000', CreateDate: tmpNow, CreatingIDUser: 1, UpdateDate: tmpNow, UpdatingIDUser: 1, Deleted: 0, DeleteDate: '', DeletingIDUser: 0, Name: 'Foo Foo', Type: 'Bunny' },
157
+ { id: 'FableTest-2', IDAnimal: 2, GUIDAnimal: '00000000-0000-0000-0000-000000000000', CreateDate: tmpNow, CreatingIDUser: 1, UpdateDate: tmpNow, UpdatingIDUser: 1, Deleted: 0, DeleteDate: '', DeletingIDUser: 0, Name: 'Red Riding Hood', Type: 'Girl' },
158
+ { id: 'FableTest-3', IDAnimal: 3, GUIDAnimal: '00000000-0000-0000-0000-000000000000', CreateDate: tmpNow, CreatingIDUser: 1, UpdateDate: tmpNow, UpdatingIDUser: 1, Deleted: 0, DeleteDate: '', DeletingIDUser: 0, Name: 'Red', Type: 'Dog' },
159
+ { id: 'FableTest-4', IDAnimal: 4, GUIDAnimal: '00000000-0000-0000-0000-000000000000', CreateDate: tmpNow, CreatingIDUser: 1, UpdateDate: tmpNow, UpdatingIDUser: 1, Deleted: 0, DeleteDate: '', DeletingIDUser: 0, Name: 'Spot', Type: 'Dog' },
160
+ { id: 'FableTest-5', IDAnimal: 5, GUIDAnimal: '00000000-0000-0000-0000-000000000000', CreateDate: tmpNow, CreatingIDUser: 1, UpdateDate: tmpNow, UpdatingIDUser: 1, Deleted: 0, DeleteDate: '', DeletingIDUser: 0, Name: 'Gertrude', Type: 'Frog' }
161
+ ];
162
+
163
+ tmpClient.add(tmpDocs, function (pAddError)
164
+ {
165
+ if (pAddError)
166
+ {
167
+ return fDone(pAddError);
168
+ }
169
+ tmpClient.commit(function (pFinalCommitError)
170
+ {
171
+ if (pFinalCommitError)
172
+ {
173
+ return fDone(pFinalCommitError);
174
+ }
175
+ _SpooledUp = true;
176
+ fDone();
177
+ });
178
+ });
179
+ });
180
+ });
181
+ }
182
+ );
183
+ }
184
+ else
185
+ {
186
+ fDone();
187
+ }
188
+ }
189
+ );
190
+
191
+ suiteTeardown((fDone) =>
192
+ {
193
+ if (libFable.MeadowSolrProvider && libFable.MeadowSolrProvider.pool)
194
+ {
195
+ var tmpClient = libFable.MeadowSolrProvider.pool;
196
+ tmpClient.deleteByQuery('*:*', function (pDeleteError)
197
+ {
198
+ if (pDeleteError) return fDone(pDeleteError);
199
+ tmpClient.commit(function ()
200
+ {
201
+ fDone();
202
+ });
203
+ });
204
+ }
205
+ else
206
+ {
207
+ fDone();
208
+ }
209
+ });
210
+
211
+ suite
212
+ (
213
+ 'Object Sanity',
214
+ function ()
215
+ {
216
+ test
217
+ (
218
+ 'The Solr class should initialize itself into a happy little object.',
219
+ function ()
220
+ {
221
+ var testMeadow = require('../source/Meadow.js').new(libFable).setProvider('Solr');
222
+ Expect(testMeadow).to.be.an('object', 'Meadow should initialize as an object directly from the require statement.');
223
+ }
224
+ );
225
+ }
226
+ );
227
+ suite
228
+ (
229
+ 'Query Processing',
230
+ function ()
231
+ {
232
+ test
233
+ (
234
+ 'Create a record in the database',
235
+ function (fDone)
236
+ {
237
+ var testMeadow = newMeadow().setIDUser(90210);
238
+
239
+ var tmpQuery = testMeadow.query.clone().setLogLevel(5)
240
+ .addRecord({ Name: 'Blastoise', Type: 'Pokemon' });
241
+
242
+ testMeadow.doCreate(tmpQuery,
243
+ function (pError, pQuery, pQueryRead, pRecord)
244
+ {
245
+ // We should have a record ....
246
+ Expect(pRecord.Name)
247
+ .to.equal('Blastoise');
248
+ Expect(pRecord.CreatingIDUser)
249
+ .to.equal(90210);
250
+ fDone();
251
+ }
252
+ )
253
+ }
254
+ );
255
+ test
256
+ (
257
+ 'Read a record from the database',
258
+ function (fDone)
259
+ {
260
+ var testMeadow = newMeadow();
261
+
262
+ var tmpQuery = testMeadow.query
263
+ .addFilter('IDAnimal', 1);
264
+
265
+ testMeadow.doRead(tmpQuery,
266
+ function (pError, pQuery, pRecord)
267
+ {
268
+ // We should have a record ....
269
+ Expect(pRecord.IDAnimal)
270
+ .to.equal(1);
271
+ Expect(pRecord.Name)
272
+ .to.equal('Foo Foo');
273
+ fDone();
274
+ }
275
+ )
276
+ }
277
+ );
278
+ test
279
+ (
280
+ 'Read all records from the database',
281
+ function (fDone)
282
+ {
283
+ var testMeadow = newMeadow();
284
+
285
+ testMeadow.doReads(testMeadow.query.addSort({Column: 'IDAnimal'}),
286
+ function (pError, pQuery, pRecords)
287
+ {
288
+ // We should have records ....
289
+ Expect(pRecords[0].IDAnimal)
290
+ .to.equal(1);
291
+ Expect(pRecords[0].Name)
292
+ .to.equal('Foo Foo');
293
+ Expect(pRecords[1].IDAnimal)
294
+ .to.equal(2);
295
+ Expect(pRecords[1].Name)
296
+ .to.equal('Red Riding Hood');
297
+ fDone();
298
+ }
299
+ )
300
+ }
301
+ );
302
+ test
303
+ (
304
+ 'Update a record in the database',
305
+ function (fDone)
306
+ {
307
+ var testMeadow = newMeadow();
308
+
309
+ var tmpQuery = testMeadow.query
310
+ .addRecord({ IDAnimal: 2, Type: 'Human' });
311
+
312
+ testMeadow.doUpdate(tmpQuery,
313
+ function (pError, pQuery, pQueryRead, pRecord)
314
+ {
315
+ // We should have a record ....
316
+ Expect(pRecord.Type)
317
+ .to.equal('Human');
318
+ fDone();
319
+ }
320
+ )
321
+ }
322
+ );
323
+ test
324
+ (
325
+ 'Delete a record in the database',
326
+ function (fDone)
327
+ {
328
+ var testMeadow = newMeadow();
329
+
330
+ var tmpQuery = testMeadow.query.addFilter('IDAnimal', 3);
331
+
332
+ testMeadow.doDelete(tmpQuery,
333
+ function (pError, pQuery, pRecord)
334
+ {
335
+ // It returns the number of rows deleted
336
+ Expect(pRecord)
337
+ .to.equal(1);
338
+ fDone();
339
+ }
340
+ )
341
+ }
342
+ );
343
+ test
344
+ (
345
+ 'Undelete a record in the database',
346
+ function (fDone)
347
+ {
348
+ var testMeadow = newMeadow();
349
+
350
+ var tmpDeleteQuery = testMeadow.query.addFilter('IDAnimal', 5);
351
+
352
+ // Make sure the record is deleted!
353
+ testMeadow.doDelete(tmpDeleteQuery,
354
+ function (pDeleteError, pDeleteQuery, pDeleteRecord)
355
+ {
356
+ var tmpQuery = testMeadow.query.addFilter('IDAnimal', 5);
357
+ testMeadow.doUndelete(tmpQuery,
358
+ function (pError, pQuery, pRecord)
359
+ {
360
+ // It returns the number of rows undeleted
361
+ Expect(pRecord)
362
+ .to.equal(1);
363
+ fDone();
364
+ });
365
+ });
366
+ }
367
+ );
368
+ test
369
+ (
370
+ 'Count all records from the database',
371
+ function (fDone)
372
+ {
373
+ var testMeadow = newMeadow();
374
+
375
+ Expect(testMeadow.query.parameters.result.executed)
376
+ .to.equal(false);
377
+ testMeadow.doCount(testMeadow.query,
378
+ function (pError, pQuery, pRecord)
379
+ {
380
+ // There should be 5 records (5 seeded + 1 created - 1 deleted = 5 non-deleted)
381
+ Expect(pRecord)
382
+ .to.equal(5);
383
+ Expect(pQuery.parameters.result.executed)
384
+ .to.equal(true);
385
+ fDone();
386
+ }
387
+ )
388
+ }
389
+ );
390
+ }
391
+ );
392
+ suite
393
+ (
394
+ 'Logged Query Processing',
395
+ function ()
396
+ {
397
+ test
398
+ (
399
+ 'Create a record in the database',
400
+ function (fDone)
401
+ {
402
+ var testMeadow = newMeadow();
403
+
404
+ var tmpQuery = testMeadow.query
405
+ .setLogLevel(5)
406
+ .addRecord({ Name: 'MewTwo', Type: 'Pokemon' });
407
+
408
+ testMeadow.doCreate(tmpQuery,
409
+ function (pError, pQuery, pQueryRead, pRecord)
410
+ {
411
+ // We should have a record ....
412
+ Expect(pRecord.Name)
413
+ .to.equal('MewTwo');
414
+ fDone();
415
+ }
416
+ )
417
+ }
418
+ );
419
+ test
420
+ (
421
+ 'Read a record from the database',
422
+ function (fDone)
423
+ {
424
+ var testMeadow = newMeadow();
425
+
426
+ var tmpQuery = testMeadow.query
427
+ .setLogLevel(5)
428
+ .addFilter('IDAnimal', 1);
429
+
430
+ testMeadow.doRead(tmpQuery,
431
+ function (pError, pQuery, pRecord)
432
+ {
433
+ // We should have a record ....
434
+ Expect(pRecord.IDAnimal)
435
+ .to.equal(1);
436
+ Expect(pRecord.Name)
437
+ .to.equal('Foo Foo');
438
+ fDone();
439
+ }
440
+ )
441
+ }
442
+ );
443
+ test
444
+ (
445
+ 'Read all records from the database',
446
+ function (fDone)
447
+ {
448
+ var testMeadow = newMeadow();
449
+
450
+ testMeadow.doReads(testMeadow.query.setLogLevel(5).addSort({Column: 'IDAnimal'}),
451
+ function (pError, pQuery, pRecords)
452
+ {
453
+ // We should have records ....
454
+ Expect(pRecords[0].IDAnimal)
455
+ .to.equal(1);
456
+ Expect(pRecords[0].Name)
457
+ .to.equal('Foo Foo');
458
+ Expect(pRecords[1].IDAnimal)
459
+ .to.equal(2);
460
+ Expect(pRecords[1].Name)
461
+ .to.equal('Red Riding Hood');
462
+ Expect(pRecords[1].Type)
463
+ .to.equal('Human');
464
+ fDone();
465
+ }
466
+ )
467
+ }
468
+ );
469
+ test
470
+ (
471
+ 'Update a record in the database',
472
+ function (fDone)
473
+ {
474
+ var testMeadow = newMeadow();
475
+
476
+ var tmpQuery = testMeadow.query
477
+ .setLogLevel(5)
478
+ .addRecord({ IDAnimal: 2, Type: 'HumanGirl' });
479
+
480
+ testMeadow.doUpdate(tmpQuery,
481
+ function (pError, pQuery, pQueryRead, pRecord)
482
+ {
483
+ // We should have a record ....
484
+ Expect(pRecord.Type)
485
+ .to.equal('HumanGirl');
486
+ fDone();
487
+ }
488
+ )
489
+ }
490
+ );
491
+ test
492
+ (
493
+ 'Delete a record in the database',
494
+ function (fDone)
495
+ {
496
+ var testMeadow = newMeadow();
497
+
498
+ var tmpQuery = testMeadow.query
499
+ .setLogLevel(5)
500
+ .addFilter('IDAnimal', 4);
501
+
502
+ testMeadow.doDelete(tmpQuery,
503
+ function (pError, pQuery, pRecord)
504
+ {
505
+ // It returns the number of rows deleted
506
+ Expect(pRecord)
507
+ .to.equal(1);
508
+ fDone();
509
+ }
510
+ )
511
+ }
512
+ );
513
+ test
514
+ (
515
+ 'Count all records from the database',
516
+ function (fDone)
517
+ {
518
+ var testMeadow = newMeadow();
519
+
520
+ testMeadow.doCount(testMeadow.query.setLogLevel(5),
521
+ function (pError, pQuery, pRecord)
522
+ {
523
+ // Solr auto-filters Deleted=0, so count is non-deleted records only
524
+ Expect(pRecord)
525
+ .to.equal(5);
526
+ fDone();
527
+ }
528
+ )
529
+ }
530
+ );
531
+ test
532
+ (
533
+ 'Create a record in the database with a defined creating user',
534
+ function (fDone)
535
+ {
536
+ var testMeadow = newMeadow();
537
+ var tmpQuery = testMeadow.query
538
+ .setIDUser(800)
539
+ .addRecord({ Name: 'MewSix', GUIDAnimal: '0x123456', Type: 'Pokemon' });
540
+
541
+ testMeadow.doCreate(tmpQuery,
542
+ function (pError, pQuery, pQueryRead, pRecord)
543
+ {
544
+ // We should have a record ....
545
+ Expect(pRecord.Name)
546
+ .to.equal('MewSix');
547
+ Expect(pRecord.CreatingIDUser)
548
+ .to.equal(800);
549
+ fDone();
550
+ }
551
+ )
552
+ }
553
+ );
554
+ }
555
+ );
556
+ suite
557
+ (
558
+ 'The Bad Kind of Query Processing',
559
+ function ()
560
+ {
561
+ test
562
+ (
563
+ 'Create a record in the database with no record',
564
+ function (fDone)
565
+ {
566
+ var testMeadow = newMeadow().setDefaultIdentifier('Type');
567
+
568
+ testMeadow.doCreate(testMeadow.query,
569
+ function (pError, pQuery, pQueryRead, pRecord)
570
+ {
571
+ Expect(pError)
572
+ .to.equal('No record submitted');
573
+ fDone();
574
+ }
575
+ )
576
+ }
577
+ );
578
+ test
579
+ (
580
+ 'Read a record from the database with no data returned',
581
+ function (fDone)
582
+ {
583
+ var testMeadow = newMeadow();
584
+
585
+ var tmpQuery = testMeadow.query
586
+ .addFilter('IDAnimal', 5000);
587
+ testMeadow.doRead(tmpQuery,
588
+ function (pError, pQuery, pRecord)
589
+ {
590
+ Expect(pRecord)
591
+ .to.equal(false);
592
+ fDone();
593
+ }
594
+ )
595
+ }
596
+ );
597
+ test
598
+ (
599
+ 'Read records from the database with no data returned',
600
+ function (fDone)
601
+ {
602
+ var testMeadow = newMeadow();
603
+
604
+ var tmpQuery = testMeadow.query
605
+ .addFilter('IDAnimal', 5000);
606
+
607
+ testMeadow.doReads(tmpQuery,
608
+ function (pError, pQuery, pRecord)
609
+ {
610
+ Expect(pRecord.length)
611
+ .to.equal(0);
612
+ fDone();
613
+ }
614
+ )
615
+ }
616
+ );
617
+ test
618
+ (
619
+ 'Update a record in the database without passing a record in',
620
+ function (fDone)
621
+ {
622
+ var testMeadow = newMeadow();
623
+
624
+ testMeadow.doUpdate(testMeadow.query,
625
+ function (pError, pQuery, pQueryRead, pRecord)
626
+ {
627
+ Expect(pError)
628
+ .to.equal('No record submitted');
629
+ fDone();
630
+ }
631
+ )
632
+ }
633
+ );
634
+ test
635
+ (
636
+ 'Update a record in the database with a bad record passed in (no default identifier)',
637
+ function (fDone)
638
+ {
639
+ var testMeadow = newMeadow();
640
+
641
+ var tmpQuery = testMeadow.query
642
+ .addRecord({ Name: 'Bill' });
643
+
644
+ testMeadow.doUpdate(tmpQuery,
645
+ function (pError, pQuery, pQueryRead, pRecord)
646
+ {
647
+ Expect(pError)
648
+ .to.equal('Automated update missing default identifier');
649
+ fDone();
650
+ }
651
+ )
652
+ }
653
+ );
654
+ test
655
+ (
656
+ 'Update a record in the database that does not exist',
657
+ function (fDone)
658
+ {
659
+ var testMeadow = newMeadow();
660
+
661
+ var tmpQuery = testMeadow.query
662
+ .addRecord({ IDAnimal: 983924 });
663
+
664
+ testMeadow.doUpdate(tmpQuery,
665
+ function (pError, pQuery, pQueryRead, pRecord)
666
+ {
667
+ // Solr returns 0 (not an object) when no docs match the filter,
668
+ // so Meadow-Update Step 2 returns 'No record updated.'
669
+ Expect(pError)
670
+ .to.equal('No record updated.');
671
+ fDone();
672
+ }
673
+ )
674
+ }
675
+ );
676
+ }
677
+ );
678
+ }
679
+ );