.insert_relation()
Inserts one or multiple relations in the database.
Method Syntaxdb.insert_relation(table, data)
Arguments | Description | ||
---|---|---|---|
table required | The table name to insert to. | ||
data required | Either a single document/record or an array of documents/records to insert |
# Insert a single record db.insert_relation('likes', { "in": RecordID('person', 'tobie'), "out": RecordID('post', 123) }) # Insert multiple records across tables people = db.insert_relation('likes', [ { "in": RecordID('person', 'tobie'), "out": RecordID('post', 123), }, { "in": RecordID('person', 'jaime'), "out": RecordID('post', 456), } ])
This function will run the following query in the database.
INSERT RELATION INTO $table $data;