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