anchor.diff:  			true -> <<>> end) /binary >> end,
   	bson:doc_foldl (AsName, <<"i">>, KeyOrder).
   
  --spec create_index (collection(), key_order(), index_uniqueness(), bson:utf8()) -> ok. % Action
  -%@doc Create index on given keys with given uniqueness and name
  -create_index (Coll, KeyOrder, Uniqueness, IndexName) ->
  -	Db = this_db (),
  -	{Unique, DropDups} = case Uniqueness of
  -		non_unique -> {false, false};
  -		unique -> {true, false};
  -		unique_dropdups -> {true, true} end,
  -	insert ('system.indexes', {
  -		ns, mongo_protocol:dbcoll (Db, Coll),
  -		key, KeyOrder,
  -		name, IndexName,
  -		unique, Unique,
  -		dropDups, DropDups}).
  -
   % Admin
   
   -spec copy_database (db(), host(), db()) -> bson:document(). % Action
  
positive.code: 
  % Index %
  
  -type key_order() :: bson:document().
  % List keys and whether ascending (1) or descending (-1). Eg. {x,1, y,-1}
  
  -spec create_index (collection(), key_order()) -> ok. % Action
  %@doc Create non-unique index on given keys in collection
  create_index (Coll, KeyOrder) ->
  	create_index (Coll, KeyOrder, non_unique).
  
  -type index_uniqueness() ::
  	non_unique |  % Multiple docs with same index value allowed
  	unique |  % At most one doc with same index value, index creation fails otherwise
  	unique_dropdups.  % Same as unique, but deletes docs with duplicate index value on index creation
  
  -spec create_index (collection(), key_order(), index_uniqueness()) -> ok. % Action
  %@doc Create index on given keys with given uniqueness
  create_index (Coll, KeyOrder, Uniqueness) ->
  	create_index (Coll, KeyOrder, Uniqueness, gen_index_name (KeyOrder)).
  
  -spec gen_index_name (key_order()) -> bson:utf8().
  gen_index_name (KeyOrder) ->
  
negative.code: -export_type ([permission/0]).
  -export ([add_user/3]).
  
  -export_type ([index_spec/0, key_order/0]).
  -export ([create_index/2]).
  
  -export ([copy_database/3, copy_database/5]).
  
  