arangosh> db.ids.ensureIndex({ type: "persistent", fields: [ "myId" ], unique: true });
{
"id" : "ids/15215",
"type" : "persistent",
"fields" : [
"myId"
],
"unique" : true,
"sparse" : false,
"isNewlyCreated" : true,
"code" : 201
}
arangosh> db.ids.save({ "myId": 123 });
{
"_id" : "ids/15218",
"_key" : "15218",
"_rev" : "_U-_q2y----"
}
arangosh> db.ids.save({ "myId": 456 });
{
"_id" : "ids/15222",
"_key" : "15222",
"_rev" : "_U-_q2y---_"
}
arangosh> db.ids.save({ "myId": 789 });
{
"_id" : "ids/15225",
"_key" : "15225",
"_rev" : "_U-_q2yC---"
}
arangosh> db.ids.save({ "myId": 123 });
[ArangoError 1210: cannot create document, unique constraint violated]