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

35 lines
1.7 KiB
Plaintext

arangod> db.ids.ensureUniqueSkiplist("myId");
{ "id" : "41236104/42612360", "unique" : true, "type" : "skiplist", "fields" : ["myId"], "isNewlyCreated" : true }
arangod> db.ids.save({ "myId": 123 });
{ "_id" : "41236104/42743432", "_rev" : 42743432 }
arangod> db.ids.save({ "myId": 456 });
{ "_id" : "41236104/42808968", "_rev" : 42808968 }
arangod> db.ids.save({ "myId": 789 });
{ "_id" : "41236104/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" : "41236104/43362549", "unique" : true, "type" : "skiplist", "fields" : ["name.first", "name.last"], "isNewlyCreated" : true }
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "hansen" }});
{ "_id" : "41236104/43755765", "_rev" : 43755765, "_key" : "43755765" }
arangod> db.ids.save({ "name" : { "first" : "jens", "last": "jensen" }});
{ "_id" : "41236104/43821301", "_rev" : 43821301, "_key" : "43821301" }
arangod> db.ids.save({ "name" : { "first" : "hans", "last": "jensen" }});
{ "_id" : "41236104/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