Like other objects in FaunaDB, databases can be created with arbitrary user data, i.e CreateDatabase({name: "bob", data:{prop: "cool"}})
. This user data can also be indexed just like anything else. An example shell session:
myDb> Get(Index("by_prop"))
{ ref: Index("by_prop"),
ts: 1560970634960000,
active: true,
partitions: 1,
name: 'by_prop',
source: Databases(),
terms: [ { field: [ 'data', 'prop' ] } ] }
myDb> Get(Database("bob"))
{ ref: Database("bob"),
ts: 1560970374730000,
name: 'bob',
data: { prop: 'cool' } }
myDb> Paginate(Match(Index("by_prop"), "cool"))
{ data: [ Database("bob") ] }
Using an index that has terms over data.prop
, I can match the database I am interested in. The choice of term / value is arbitrary and can be whatever makes sense for your application.