MRS SDK 参考
本文档介绍如何使用 MRS 软件开发工具包以及讨论客户端 API。
章节概述
另请参见
- MySQL REST 服务 - 开发者指南 - 本书介绍如何安装和配置 MySQL REST 服务 (MRS) 以及如何通过 REST 调用访问数据。
- MySQL REST 服务 - 核心 REST API - 本书提供对表和视图执行 MySQL REST 服务查询和其他操作的示例,前提是您已对其启用 REST。
- MySQL REST 服务 - SQL 参考 - 本书讨论 MySQL REST 服务 SQL 扩展。
1 MRS SDK 简介
MySQL REST 服务提供了一个软件开发工具包 (SDK),它简化了编写客户端应用程序和与 REST 服务交互的过程。
SDK 包含一个专门为每个 MRS REST 服务生成的客户端 API,因此为每个 REST 项目提供最佳支持。
目前,支持 TypeScript。计划支持其他语言。
1.1 SDK 文件生成
1.1.1 动态生成 TypeScript SDK
VS Code 的 MySQL Shell 扩展允许在 DB 笔记本中交互式执行 TypeScript 代码。为了更轻松地使用 MySQL REST 服务,当前 REST 服务的 TypeScript SDK 直接在 DB 笔记本中提供。
只要 REST DB 对象被编辑,TypeScript SDK 就会更新,以允许使用客户端 API 立即对 REST 查询进行原型设计。
这允许调整和微调 REST DB 对象,直到它们完全满足开发人员的要求,并为开发项目原型化客户端 API 调用。
1.1.2 为开发项目生成 SDK 文件
要为开发项目生成 SDK 文件,请右键单击 MRS 服务并选择“导出 REST 服务 SDK 文件...” 。这将允许您选择将文件放置在开发项目中的目标文件夹。
以下文件将被放置在所选文件夹中。
TypeScript
MrsBaseClasses.ts
- 包含客户端 API 使用的 MRS 基类的文件<RestServiceName>.ts
- 使用服务名称的特定 REST 服务的客户端 API。config.json
- 用于 SDK 生成的配置文件
要开始使用客户端 API,请在项目中导入 <RestServiceName>.ts
文件。
2 跨表查询数据
MySQL 支持外键,允许跨表交叉引用相关数据,并支持外键约束,以帮助保持相关数据的完整性。
外键关系涉及一个父表,它包含初始列值,以及一个子表,其列值引用父表列值。外键约束定义在子表上。外键能够在这些表中行的之间建立一对一、一对多或多对多的关系。
使用 MySQL REST 服务,这些关系可以扩展到包括来自不同表的相关数据,这些相关数据嵌入在同一个结果集中,每个 MRS 数据库对象都具有 JSON 关系二元性功能。然后,客户端可以使用特定的 HTTP 查询语法选择要扩展哪些列,以指定并沿着其他表上列的嵌套路径进行导航,这些列由主表(或父表)中的根列引用。
MRS SDK 的一个关键功能是能够查询两个数据库对象之间的这些关系,并在查询响应中包含或排除特定列。
此功能可通过以下 API 命令中的 select
选项使用
findFirst()
findMany()
findUnique()
默认情况下,查询响应中返回所有对象字段(扩展或未扩展)及其值。可以使用纯对象格式从查询响应中排除特定字段,其中属性是要排除的字段的名称,每个值都是 false
。
使用 Sakila 示例数据库 进行设置,其中模式在名为 myService
的 REST 服务下可用,并且城市和国家表之间的关系(一对一)通过 JSON/关系二元性功能扩展,可以如下排除 lastUpdate
和 country.lastUpdate
字段
.sakila.city.findFirst({ select: { lastUpdate: false, country: { lastUpdate: false } } })
myService
{"city": "A Coruña (La Coruña)",
"links": [
{"rel": "self",
"href": "/myService/sakila/city/1"
},
]"cityId": 1,
"country": {
"country": "Spain",
"countryId": 87
,
}"countryId": 87
}
同样,如果扩展了 actor
和 film
表(多对多)之间的关系,则以下命令将排除每个嵌套对象上的标识符
.sakila.actor.findFirst({ select: { filmActor: { actorId: false, film: { filmId: false, languageId: false, originalLanguageId: false } } } })
myService
{
{"links": [
{"rel": "self",
"href": "/myService/sakila/actor/58"
},
]"actorId": 58,
"lastName": "AKROYD",
"filmActor": [
{"film": {
"title": "BACKLASH UNDEFEATED",
"length": 118,
"rating": "PG-13",
"lastUpdate": "2006-02-15 05:03:42.000000",
"rentalRate": 4.99,
"description": "A Stunning Character Study of a Mad Scientist And a Mad Cow who must Kill a Car in A Monastery",
"releaseYear": 2006,
"rentalDuration": 3,
"replacementCost": 24.99,
"specialFeatures": "Trailers,Behind the Scenes"
,
}"filmId": 48,
"lastUpdate": "2006-02-15 05:05:03.000000"
,
}// ...
,
]"firstName": "CHRISTIAN",
"lastUpdate": "2006-02-15 04:34:33.000000"
}
另一方面,可以使用相同的对象格式并将值设置为 true
,或者使用要包含的字段名称列表,将字段挑选出来并包含在查询响应中。
同样,这对一对一关系也是可能的
.sakila.city.findFirst({ select: { city: true, country: { country: true } } })
myService
{"city": "A Coruña (La Coruña)",
"links": [
{"rel": "self",
"href": "/myService/sakila/city/1"
},
]"country": {
"country": "Spain",
} }
以及多对多关系
.sakila.actor.findFirst({ select: ['filmActor.film.title'] })
myService
{
{"links": [
{"rel": "self",
"href": "/myService/sakila/actor/58"
},
]"filmActor": [
{"film": {
"title": "BACKLASH UNDEFEATED"
},
}
{"film": {
"title": "BETRAYED REAR"
}
}// ...
] }
3 检查 NULL 列值
MySQL 支持 NOT NULL
约束,它确保给定列中的值不能为 NULL。但从遗漏的角度来看,列可以包含 NULL
值。使用 MySQL REST 服务,可以使用 $null
或 $notnull
运算符将包含(或不包含)NULL 值的列的记录包含在结果集中或从结果集中排除。
TypeScript MRS SDK 为在给定字段包含(或不包含)NULL
值时对结果集中记录进行过滤提供了一种特殊的语法。使用 Sakila 示例数据库 进行设置,其中模式在名为 myService
的 REST 服务下可用,可以通过以下方式对 NULL 列值进行过滤记录
.sakila.address.findMany({ select: ["address", "address2"], where: { address2: null } })
myService
{"items": [
{"links": [
{"rel": "self",
"href": "/myService/sakila/address/1"
},
]"address": "47 MySakila Drive",
"address2": null,
"_metadata": {
"etag": "44EA44E1541A6A0A24135C4CC4F30E52AA2B4256181DE9BC1960C78A35F33B27"
},
}
{"links": [
{"rel": "self",
"href": "/myService/sakila/address/2"
},
]"address": "28 MySQL Boulevard",
"address2": null,
"_metadata": {
"etag": "C5C68338EBF92980E1B8FDAE3FE7E3CE9507C4169C3DEC1BDB4E9AF2D961E00D"
},
}
{"links": [
{"rel": "self",
"href": "/myService/sakila/address/3"
},
]"address": "23 Workhaven Lane",
"address2": null,
"_metadata": {
"etag": "7EF99DD02DF9071C8946B6180E74EB11D6B47FDD03A36C9B44B920F2A8D3684B"
},
}
{"links": [
{"rel": "self",
"href": "/myService/sakila/address/4"
},
]"address": "1411 Lillydale Drive",
"address2": null,
"_metadata": {
"etag": "5F4F5E570F2AF2BB5E5A7AE41548CE4965F715F7C040A80B42D0DB79BB57336B"
}
},
]"limit": 25,
"offset": 0,
"hasMore": false,
"count": 4,
"links": [
{"rel": "self",
"href": "/myService/sakila/address/"
}
] }
同样,可以通过以下方式过滤给定列不包含 NULL
的记录
.sakila.actor.findFirst({ select: ["address", "address2"], where: { address2: { not: null } } })
myService
{"links": [
{"rel": "self",
"href": "/myService/sakila/address/5"
},
]"address": "1913 Hanoi Way",
"address2": "",
"_metadata": {
"etag": "689439C1F6D1F101E9A146F8DE244F01F0CE40AEBFA92AE5CEABA119F9C1573E"
} }
尝试对映射到包含 NOT NULL
约束的列的字段应用此类过滤器应会产生 TypeScript 编译错误
.sakila.actor.findFirst({ where: { address: null } }) myService
Type 'null' is not assignable to type 'string | DataFilterField<IMyServiceSakilaAddressParams, string | undefined> | ComparisonOpExpr<string | undefined>[] | undefined'.
4 使用空间数据类型
MySQL 支持基于 OpenGIS 几何模型中建立的约定扩展的 SQL 环境,它允许一组空间列数据类型保存几何值。其中一些保存单个值
GEOMETRY
POINT
LINESTRING
POLYGON
GEOMETRY
可以保存任何类型的几何值。其他单值类型(POINT
、LINESTRING
和 POLYGON
)将它们的值限制为特定几何类型。
另一方面,有一些空间数据类型用于保存几何值的集合
MULTIPOINT
MULTILINESTRING
MULTIPOLYGON
GEOMETRYCOLLECTION
GEOMETRYCOLLECTION
可以保存任何类型的对象的集合。其他集合类型(MULTIPOINT
、MULTILINESTRING
和 MULTIPOLYGON
)将集合成员限制为具有特定几何类型的成员。
MySQL Rest 服务 SDK 支持两种格式来表示、操作或操作空间数据
- Well-Known Text (WKT)
- GeoJSON
在插入或更新包含与空间数据类型列匹配的字段的记录时,可以使用这两种格式。
例如,使用 Sakila 示例数据库 进行设置,其中模式在名为 myService
的 REST 服务下可用,在将记录插入 address
表时,您可以指定 location
列的值(它具有泛型 GEOMETRY
数据类型),如下所示
// WKT
.sakila.address.create({ data: { location: "Point(11.11 12.22)" }})
myService
.sakila.address.createMany([{
myService: {
data: "Point(0 0)"
location
}, {
}: {
data: "Point(11.11 12.22)"
location
}
}])
// GeoJSON
.sakila.address.create({ data: {
myService: {
location: "Point",
type: [11.11, 12.22]
coordinates
} }})
相同的约定也应适用于更新同一表上的记录。
// WKT
.sakila.address.update({
myService: {
where: 1
address_id
}: {
data: "Point(11.11 12.22)"
location
}
})
.sakila.address.updateMany({
myService: [{
where: 1
address_id, {
}: 2
address_id,
}]: {
data: "Point(11.11 12.22)"
location
}
})
// GeoJSON
.sakila.address.update({
myService: {
where: 1
address_id
}: {
data: {
location: "Point",
type: [11.11, 12.22]
coordinates
}
}
})
.sakila.address.updateMany({
myService: [{
where: 1
address_id, {
}: 2
address_id,
}]: {
data: {
location: "Point",
type: [11.11, 12.22]
coordinates
}
} })
如果列具有更窄的数据类型,例如 POINT
,而不是更通用的 GEOMETRY
,在客户端指定不兼容的类型应会产生编译错误。例如,假设如下创建了一个表 mrs_tests
.spatial_tests
CREATE DATABASE IF NOT EXISTS mrs_tests;
CREATE TABLE IF NOT EXISTS mrs_tests.spatial_tests (id INT AUTO_INCREMENT NOT NULL, ls LINESTRING, PRIMARY KEY (id));
从同一个 myService
REST 服务提供该表(和相应的模式),尝试插入 POINT
无法正常工作,因为该列只接受 LINESTRING
。
.mrsTests.spatialTests.create({
myService: {
data: {
ls: "Point",
type: [0, 0]
coordinates
}
} })
类似上面的命令会导致编译错误。
类型“Point”无法分配给类型“LineString”。
同样,当列数据类型只允许单个值时,尝试为单个字段插入或更新多个值,反之亦然,也会产生编译错误。例如,假设 mrs_tests.spatial_tests
表如下创建
CREATE TABLE IF NOT EXISTS mrs_tests.wl15912 (id INT AUTO_INCREMENT NOT NULL, ls GEOMETRYCOLLECTION, PRIMARY KEY (id));
尝试插入 POINT
无法正常工作,因为该列只接受 MULTIPOINT
、MULTILINESTRING
或 MULTIPOLYGON
之一。
.mrsTests.spatialTests.create({
myService: {
data: {
ls: "Point",
type: [0, 0]
coordinates
}
} })
在这种情况下,该命令会产生以下编译错误
类型“Point”无法分配给类型“MultiPoint | MultiLineString | MultiPolygon”。
5 TypeScript 客户端 API 参考
5.1 create
create
用于在给定表中插入记录。该记录表示为一个普通的 TypeScript/JavaScript 对象,或者表示为一个特定类的实例,该实例封装了创建新记录所需的数据。要插入多条记录,请参见 createMany
[#createMany]。
5.1.1 选项 (create)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
data | object | 是 | 包含要插入的记录的列名和值之间映射的对象。 |
5.1.2 返回类型 (create)
表示插入记录的 JSON 对象。
5.1.3 参考 (create)
async function create (args: ICreateOptions<Type>): Promise<Type> {
// ...
}
interface ICreateOptions<Type> {
: Type
data }
5.1.4 示例 (create)
import type { IMyServiceMrsNotesNote } from '/path/to/sdk/myService';
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// using a plain object
.mrsNotes.note.create({ data: { title: 'foo' } });
myService
// using a custom class instance
class Note implements IMyServiceMrsNotesNote {
// ...
}
const note = new Note();
.title = 'foo';
note
.mrsNotes.note.create({ data: note }); myService
5.2 createMany
createMany
在给定表中插入一条或多条记录。这些记录表示为普通的 TypeScript/JavaScript 对象,或者表示为一个特定类的实例,该实例封装了创建它们所需的数据。
5.2.1 选项 (create)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
data | object | 是 | 包含要插入的记录的列名和值之间映射的对象数组。 |
5.2.2 返回类型 (createMany)
表示插入记录的 JSON 对象数组。
5.2.3 参考 (createMany)
async function createMany (args: ICreateOptions<Type[]>): Promise<Type[]> {
// ...
}
interface ICreateOptions<Type> {
: Type
data }
5.2.4 示例 (createMany)
import type { IMyServiceMrsNotesNote } from '/path/to/sdk/myService';
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// using a plain object
.mrsNotes.note.createMany({ data: [{ title: 'foo' }, { title: 'bar' }] });
myService
// using a custom class
class Note implements IMyServiceMrsNotesNote {
// ...
}
const note1 = new Note();
.title = 'foo';
note1
const note2 = new Note({ /* */ });
.title = 'bar';
note1
.mrsNotes.note.createMany({ data: [note1, note2] }); myService
5.3 findFirst
findFirst
用于查询第一个匹配给定可选过滤器的记录。
5.3.1 选项 (findFirst)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
where | object | 否 | 应用于特定字段的过滤条件。 |
select | object | 否 | 指定要包含在返回对象中的属性。 |
skip | number | 否 | 指定在返回匹配项之一之前要跳过的记录数。 |
5.3.2 返回类型 (findFirst)
表示第一个匹配过滤器的记录的 JSON 对象,或者当未找到该记录时为 undefined
。
5.3.3 参考 (findFirst)
async function findFirst (args?: IFindOptions<Selectable, Filterable>): Promise<Selectable | undefined> {
// ...
}
export interface IFindOptions<Selectable, Filterable> {
?: ColumnOrder<Filterable>,
orderBy?: BooleanFieldMapSelect<Selectable> | FieldNameSelect<Selectable>,
select?: number,
skip?: DataFilter<Filterable>,
where }
5.3.4 示例 (findFirst)
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// get the first note, without any filter
await myService.mrsNotes.note.findFirst();
// get the last note, without any filter
await myService.mrsNotes.note.findFirst({ orderBy: { id: "DESC" } });
// get the second note, without any filter
await myService.mrsNotes.note.findFirst({ skip: 1 });
// get the title and shared fields of the second note
await myService.mrsNotes.note.findFirst({ select: { title: true, shared: true }, skip: 1 });
// get the title and shared fields of the first note
await myService.mrsNotes.note.findFirst({ select: ["title", "shared"] });
// get the first shared note
await myService.mrsNotes.note.findFirst({ where: { shared: true } });
// get the first note whose title includes the string "foo"
await myService.mrsNotes.note.findFirst({ where: { title: { $like: "%foo%" } } });
5.4 findUnique
findUnique
用于通过以下方式查询单个唯一标识的记录:
- 主键列
- 唯一列
如果未找到与给定where
条件匹配的记录,则返回undefined
。若要在此情况下抛出异常,请参见 findUniqueOrThrow。
5.4.1 选项 (findUnique)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
where | object | 是 | 封装所有唯一列,以便可以选择单个记录。 |
select | object | 否 | 指定要包含在返回对象中的属性。 |
5.4.2 返回类型 (findUnique)
一个 JSON 对象,表示与过滤器匹配的特定记录,或者在未找到记录时返回undefined
。
5.4.3 引用 (findUnique)
async function findUnique (args?: IFindUniqueOptions<Selectable, Filterable>): Promise<Selectable | undefined> {
// ...
}
interface IFindUniqueOptions<Selectable, Filterable> {
?: BooleanFieldMapSelect<Selectable> | FieldNameSelect<Selectable>,
select?: DataFilter<Filterable>,
where }
5.4.4 示例 (findUnique)
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// Get the note with id 4.
// using implicit equality
await myService.mrsNotes.note.findUnique({ where: { id: 4 } });
// or using explicit equality
await myService.mrsNotes.note.findUnique({ where: { id: { $eq: 4 } } });
5.5 findUniqueOrThrow
findUniqueOrThrow
以与 findUnique 相同的方式检索单个数据记录。但是,如果查询未找到记录,它将抛出一个NotFoundError
。
findUniqueOrThrow
与 findUnique
的区别在于:
- 它的返回类型是非空类型。例如,myService.mrsNotes.note.findUnique() 可以返回一个 note 或者 undefined,但 myService.mrsNotes.note.findUniqueOrThrow() 始终返回一个 note。
5.6 findMany
findMany
用于查询一页或多页中的所有记录,并且可以选择那些与给定过滤器匹配的记录。
5.6.1 选项 (findMany)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
where | object | 否 | 应用于特定字段的过滤条件。 |
select | object | 否 | 指定要包含在返回对象中的属性。 |
skip | number | 否 | 在返回匹配项之一之前跳过的记录数。 |
take | number | 否 | 要返回的最大记录数。 |
fetchAll | object | 布尔值 | 否 |
5.6.2 返回类型 (findMany)
一个 JSON 对象数组,表示与过滤器匹配的记录。
5.6.3 引用 (findMany)
async function findMany (args?: IFindOptions<Selectable, Filterable>): Promise<IMrsResultList<Selectable>> {
// ...
}
interface IFindOptions<Selectable, Filterable> {
?: IFindAllOptions<Selectable> | boolean,
fetchAll?: ColumnOrder<Filterable>,
orderBy?: BooleanFieldMapSelect<Selectable> | FieldNameSelect<Selectable>,
select?: number,
skip?: number,
take?: DataFilter<Filterable>,
where }
5.6.4 示例 (findMany)
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// get all notes of the first page
await myService.mrsNotes.note.findMany();
// get the first 3 notes of the first page
await myService.mrsNotes.note.findMany({ take: 3 });
// get the first 50 notes
await myService.mrsNotes.note.findMany({ fetchAll: true, take: 50 });
// get all notes whose id is greater than 10
await myService.mrsNotes.note.findMany({ fetchAll: true, where: { id: { $gt: 10 } } });
5.7 delete
delete
用于删除与给定必需过滤器匹配的第一条记录。
5.7.1 选项 (delete)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
where | object | 是 | 应用于特定字段的过滤条件。 |
5.7.2 返回类型 (delete)
一个 JSON 对象,包含已删除的记录数(始终为 1)。
5.7.3 引用 (delete)
async function delete (args: IDeleteOptions<IMyServiceMrsNotesUserParams>): Promise<IMrsDeleteResult> {
// ...
}
interface IDeleteOptions<Filterable> {
?: DataFilter<Filterable>,
where
}
interface IMrsDeleteResult {
: 1,
itemsDeleted }
5.7.4 示例 (delete)
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// delete the first note whose title includes the string "foo"
await myService.mrsNotes.note.delete({ where: { title: { $like: "%foo%" } } });
5.8 deleteMany
delete
用于删除与给定过滤器匹配的所有记录。
5.8.1 选项 (deleteMany)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
where | object | 否 | 应用于特定字段的过滤条件。 |
5.8.2 返回类型 (deleteMany)
一个 JSON 对象,包含已删除的记录数。
5.8.3 引用 (deleteMany)
async function deleteMany (args: IDeleteOptions<IMyServiceMrsNotesUserParams>): Promise<IMrsDeleteResult> {
// ...
}
interface IDeleteOptions<Filterable> {
?: DataFilter<Filterable>,
where
}
interface IMrsDeleteResult {
: number,
itemsDeleted }
5.8.4 示例 (deleteMany)
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// delete all notes whose title includes the string "foo"
await myService.mrsNotes.note.deleteMany({ where: { title: { $like: "%foo%" } } });
// delete all shared notes
await myService.mrsNotes.note.deleteMany({ where: { shared: true } });
5.9 update
update
用于使用给定标识符或主键更新记录。
5.9.1 选项 (update)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
data | object | 是 | 要更新的字段集及其对应值。 |
where | object | 是 | 匹配的标识符或主键。 |
5.9.2 返回类型 (update)
一个 JSON 对象,表示最新的记录。
5.9.3 引用 (update)
async function update (args: IUpdateOptions<Data, Filterable, ["id"], { batch: false }>): Promise<Data> {
// ...
}
interface IUpdateOptions<Data, Filterable, PrimaryKeys extends Array<string & keyof Filterable>, Config> {
: Data,
data: Config extends IBatchConfig ? Array<UpdateMatch<Filterable, PrimaryKeys>> : UpdateMatch<Filterable, PrimaryKeys>
where
}
interface IBatchConfig {
: true
batch }
5.9.4 示例 (update)
import type { IMyServiceMrsNotesNote } from '/path/to/sdk/myService';
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// update the note with id is 1 using a plain object
await myService.mrsNotes.note.update({ where: { id: 1 }, data: { title: 'bar' } } );
// using a custom class instance
class Note implements IMyServiceMrsNotesNote {
// ...
}
const note = new Note();
.shared = false;
note
// update the note with id 1
await myService.mrsNotes.note.update({ where: { id: 1 }, data: note });
5.10 updateMany
updateMany
用于更新所有与匹配标识符或主键的记录。
5.10.1 选项 (updateMany)
名称 | 类型 | 必需 | 描述 |
---|---|---|---|
data | object | 是 | 要更新的字段集及其对应值。 |
where | object | 是 | 匹配的标识符或主键。 |
5.10.2 返回类型 (updateMany)
一个 JSON 对象数组,表示最新的记录。
5.10.3 引用 (updateMany)
async function updateMany (args: IUpdateOptions<Data, Filterable, ["id"], { batch: true }>): Promise<Data[]> {
// ...
}
interface IUpdateOptions<Data, Filterable, PrimaryKeys extends Array<string & keyof Filterable>, Config> {
: Data,
data: Config extends IBatchConfig ? Array<UpdateMatch<Filterable, PrimaryKeys>> : UpdateMatch<Filterable, PrimaryKeys>
where
}
interface IBatchConfig {
: true
batch }
5.10.4 示例 (updateMany)
import type { IMyServiceMrsNotesNote } from '/path/to/sdk/myService';
import { MyService } from './myService.mrs.sdk/myService';
const myService = new MyService();
// update the notes with id 1 and 2 using a plain object
await myService.mrsNotes.note.update({ where: [{ id: 1 }, { id: 2 }], data: { title: 'bar' } });
// using a custom class instance
class Note implements IMyServiceMrsNotesNote {
// ...
}
const note = new Note();
.shared = false;
note
// update the note with id 1 and 2
await myService.mrsNotes.note.update({ where: [{ id: 1 }, { id: 2 }], data: note });
版权所有 (c) 2022, 2023,Oracle 和/或其关联公司。