1
0
Fork 0
arangodb/Documentation/Examples/unique-skiplist

35 lines
1.7 KiB
Plaintext

arangod> db.ids.ensureUniqueSkiplist("myId");
{ "id" : "ids/42612360", "unique" : true, "type" : "skiplist", "fields" : ["myId"], "isNewlyCreated" : true }
arangod> db.ids.save({ "myId": 123 });
{ "_id" : "ids/42743432", "_key" : "42743432", "_rev" : "42743432" }
arangod> db.ids.save({ "myId": 456 });
{ "_id" : "ids/42808968", "_key" : "42808968", "_rev" : "42808968" }
arangod> db.ids.save({ "myId": 789 });
{ "_id" : "ids/42874504", "_key" : "42874504", "_rev" : "42874504" }
arangod> db.ids.save({ "myId": 123 });
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
!db.ids.save({ "myId": 123 });
! ^
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
at (arango):1:8
arangod> db.ids.ensureUniqueSkiplist("name.first", "name.last");
{ "id" : "ids/43362549", "unique" : true, "type" : "skiplist", "fields" : ["name.first", "name.last"], "isNewlyCreated" : true }
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
{ "_id" : "ids/43755765", "_rev" : "43755765", "_key" : "43755765" }
arangod> db.ids.save({ "name" : { "first" : "jens", "last": "jensen" }});
{ "_id" : "ids/43821301", "_rev" : "43821301", "_key" : "43821301" }
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "jensen" }});
{ "_id" : "ids/43886837", "_rev" : "43886837", "_key" : "43886837" }
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
JavaScript exception in file '(arango)' at 1,8: [ArangoError 1210: cannot save document: unique constraint violated]
!db.ids.save({"name" : {"first" : "hans", "last": "hansen" }});
! ^
stacktrace: [ArangoError 1210: cannot save document: unique constraint violated]
at (arango):1:8