arangosh> db.ids.ensureIndex({ type: "persistent", fields: [ "myId" ], unique: true });
{
"id" : "ids/16084",
"type" : "persistent",
"fields" : [
"myId"
],
"unique" : true,
"sparse" : false,
"isNewlyCreated" : true,
"code" : 201
}
arangosh> db.ids.save({ "myId": 123 });
{
"_id" : "ids/16087",
"_key" : "16087",
"_rev" : "16087"
}
arangosh> db.ids.save({ "myId": 456 });
{
"_id" : "ids/16091",
"_key" : "16091",
"_rev" : "16091"
}
arangosh> db.ids.save({ "myId": 789 });
{
"_id" : "ids/16094",
"_key" : "16094",
"_rev" : "16094"
}
arangosh> db.ids.save({ "myId": 123 });
[ArangoError 1210: cannot create document, unique constraint violated]