MoveDatabase
MoveDatabase( from, to )
MoveDatabase( from, to )
MoveDatabase( from, to )
MoveDatabase( from, to )
move_database( from, to )
MoveDatabase( from, to )
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.
Examples
The following example creates the stamps
database and the hobbies
database, and then moves the stamps
database into the hobbies
database:
Field<RefV> REF_FIELD = Field.At("ref").To<RefV>();
Value stamps = await client.Query(
CreateDatabase(Obj("name", "stamps"))
);
Value hobbies = await client.Query(
CreateDatabase(Obj("name", "hobbies"))
);
Value result = await client.Query(
MoveDatabase(stamps.Get(REF_FIELD), hobbies.Get(REF_FIELD))
);
var refField = f.ObjKey("ref")
var stampsRef, hobbiesRef f.RefV
stamps, err := client.Query(
f.CreateDatabase(f.Obj{"name": "stamps"}))
if (err != nil) {
fmt.Println(err)
}
stamps.At(refField).Get(&stampsRef)
hobbies, err := client.Query(
f.CreateDatabase(f.Obj{"name": "hobbies"}))
if (err != nil) {
fmt.Println(err)
}
hobbies.At(refField).Get(&hobbiesRef)
result, err := client.Query(
f.MoveDatabase(stampsRef, hobbiesRef))
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))
stamps = client.query(
q.create_database({"name": "stamps"})
)
hobbies = client.query(
q.create_database({ "name": "hobbies"})
)
print(client.query(
q.move_database(stamps["ref"], hobbies["ref"])
))
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.
{
"object": {
"ref": {
"@ref": {
"id": "stamps",
"collection": {
"@ref": {
"id": "databases"
}
},
"database": {
"@ref": {
"id": "hobbies",
"collection": {
"@ref": {
"id": "databases"
}
}
}
}
}
},
"ts": 1574381591150000,
"name": "stamps"
}
}
map[name:stamps ref:{stamps 0xc0000a0300 0xc0000a0300 0xc0000a0360} ts:1574379502810000]
{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': 1574370715820000,
'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!