From b0ef3b73a8e9bf3426bee0d18c9e12bbfc55ff3f Mon Sep 17 00:00:00 2001 From: zyazhb Date: Tue, 3 Sep 2024 15:28:38 +0800 Subject: [PATCH] Support relate statement --- db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db.go b/db.go index f73f2da..7040733 100644 --- a/db.go +++ b/db.go @@ -130,6 +130,11 @@ func (db *DB) LiveNotifications(liveQueryID string) (chan model.Notification, er return db.conn.LiveNotifications(liveQueryID) } +// Create a relation between two records. The data parameter is optional. +func (db *DB) Relate(fromRecordId, table, toRecordId, data interface{}) (interface{}, error) { + return db.send("relate", fromRecordId, table, toRecordId, data) +} + // -------------------------------------------------- // Private methods // -------------------------------------------------- @@ -143,7 +148,7 @@ func (db *DB) send(method string, params ...interface{}) (interface{}, error) { } switch method { - case "select", "create", "update", "merge", "patch", "insert": + case "select", "create", "update", "merge", "patch", "insert", "relate": return db.resp(method, params, resp) case "delete": return nil, nil