MoveDatabase

MoveDatabase( from, to )
MoveDatabase( from, to )
MoveDatabase( from, to )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.

Description

The MoveDatabase function moves the from database into the to database, making from a child database of to.

You must use an admin key that has access to the from database or MoveDatabase fails.

Parameters

Argument Type Definition and Requirements

from

A database ref for the database to be moved.

to

A database ref for the new parent database of from.

Returns

A database ref for the moved database.

Examples

The following example creates the stamps database and the hobbies database, and then moves the stamps database into the hobbies database:

Value stamps = client.query(
    CreateDatabase(Obj("name", Value("stamps")))
).get();
Value hobbies = client.query(
    CreateDatabase(Obj("name", Value("hobbies")))
).get();
System.out.println(
    client.query(
        MoveDatabase(
            stamps.get(Field.at("ref")),
            hobbies.get(Field.at("ref"))
        )
    ).get()
);
Promise.all([
  client.query(q.CreateDatabase({ name: 'stamps' })),
  client.query(q.CreateDatabase({ name: 'hobbies' })),
])
.then(([stamps, hobbies]) => client.query(
  q.MoveDatabase(stamps.ref, hobbies.ref)
))
.then((ret) => console.log(ret))
  val stamps = Await.result(client.query(
    CreateDatabase(Obj("name" -> "stamps"))
  ), 5.seconds)
  val hobbies = Await.result(client.query(
    CreateDatabase(Obj("name" -> "hobbies"))
  ), 5.seconds)
  println(Await.result(client.query(
      MoveDatabase(stamps("ref").get, hobbies("ref").get)
  ), 5.seconds))
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
{ref: ref(id = "stamps", collection = ref(id = "databases"), database = ref(id = "hobbies", collection = ref(id = "databases"))), ts: 1570141207930000, name: "stamps"}
Moved: { ref: Database("stamps", Database("hobbies")),
  ts: 1570137825180000,
  name: 'stamps' }
{ref: ref(id = "stamps", collection = ref(id = "databases"), database = ref(id = "hobbies", collection = ref(id = "databases"))), ts: 1570139962250000, name: "stamps"}

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!