1
0
Fork 0
arangodb/Documentation/Examples/ensureUniqueConstraint.gene...

31 lines
768 B
Plaintext

arangosh> db.test.ensureUniqueConstraint("a", "b.c");
{
"id" : "test/1180103563",
"type" : "hash",
"fields" : [
"a",
"b.c"
],
"selectivityEstimate" : 1,
"unique" : true,
"sparse" : false,
"isNewlyCreated" : true,
"code" : 201
}
arangosh> db.test.save({ a : 1, b : { c : 1 } });
{
"_id" : "test/1180431243",
"_rev" : "1180431243",
"_key" : "1180431243"
}
arangosh> db.test.save({ a : 1, b : { c : 1 } });
[ArangoError 1210: cannot create document, unique constraint violated]
arangosh> db.test.save({ a : 1, b : { c : null } });
{
"_id" : "test/1180889995",
"_rev" : "1180889995",
"_key" : "1180889995"
}
arangosh> db.test.save({ a : 1 });
[ArangoError 1210: cannot create document, unique constraint violated]