.insert()
Inserts one or multiple records in the database.
Method Syntaxdb.insert(thing, data)
Arguments | Description | ||
---|---|---|---|
thing 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('person', { "name": 'Tobie', "settings": { "active": True, "marketing": True, }, }) # Insert multiple records db.insert('person', [ { "name": 'Tobie', "settings": { "active": True, "marketing": True, }, }, { "name": 'Jaime', "settings": { "active": True, "marketing": True, }, }, ])
This function will run the following query in the database.
INSERT INTO $thing $data;
You can insert relations using the insert_relation()
method.