From 5a317a13f7a22e49f328512dba7f3abf23046c65 Mon Sep 17 00:00:00 2001 From: tianwei <36880544+TiannV@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:33:45 +0800 Subject: [PATCH] =?UTF-8?q?database=E7=AB=A0=E8=8A=82=E6=B1=89=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/spec/combined.json | 54 ++++++++-------- web/spec/dart.yml | 126 +++++++++++++++++-------------------- web/spec/supabase.yml | 140 +++++++++++++++++------------------------ 3 files changed, 141 insertions(+), 179 deletions(-) diff --git a/web/spec/combined.json b/web/spec/combined.json index 903d7441..ea858b4e 100644 --- a/web/spec/combined.json +++ b/web/spec/combined.json @@ -1131,7 +1131,7 @@ "isExported": true }, "comment": { - "text": "The function name to call." + "text": "要调用的函数名." }, "type": { "type": "intrinsic", @@ -1148,7 +1148,7 @@ "isOptional": true }, "comment": { - "text": "The parameters to pass to the function call." + "text": "传递给函数调用的参数." }, "type": { "type": "union", @@ -1193,7 +1193,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n\n" + "text": "用于对表中的行进行计数的计数算法.\n\n" }, "sources": [ { @@ -5200,7 +5200,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法.\n" }, "sources": [ { @@ -5244,7 +5244,7 @@ "isExported": true }, "comment": { - "text": "If `true`, return the deleted row(s) in the response." + "text": "如果为'true',则在响应中返回已删除的行。" }, "sources": [ { @@ -5353,7 +5353,7 @@ "isExported": true }, "comment": { - "text": "The values to insert." + "text": "插入的值." }, "type": { "type": "union", @@ -5919,7 +5919,7 @@ "isExported": true }, "comment": { - "shortText": "Performs vertical filtering with SELECT." + "shortText": "使用 SELECT 执行垂直过滤。" }, "parameters": [ { @@ -5932,7 +5932,7 @@ "isOptional": true }, "comment": { - "text": "The columns to retrieve, separated by commas." + "text": "要检索的列,以逗号分隔。" }, "type": { "type": "union", @@ -5978,7 +5978,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法.\n" }, "sources": [ { @@ -6022,7 +6022,7 @@ "isExported": true }, "comment": { - "text": "When set to true, select will void data." + "text": "设置为 true 时,select 将使数据无效." }, "sources": [ { @@ -6525,7 +6525,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于计算表中行数的计数算法.\n" }, "sources": [ { @@ -6678,7 +6678,7 @@ "isExported": true }, "comment": { - "text": "The values to insert." + "text": "插入的值." }, "type": { "type": "union", @@ -6739,7 +6739,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table." + "text": "用于对表中的行进行计数的计数算法." }, "sources": [ { @@ -6783,7 +6783,7 @@ "isExported": true }, "comment": { - "text": "Specifies if duplicate rows should be ignored and not inserted.\n" + "text": "指定重复行是否应忽略而不插入.\n" }, "sources": [ { @@ -6851,7 +6851,7 @@ "isExported": true }, "comment": { - "text": "By default the new record is returned. Set this to 'minimal' if you don't need this value." + "text": "默认情况下返回新记录。如果您不需要此值,请将其设置为'minimal'" }, "sources": [ { @@ -22676,7 +22676,7 @@ "isExported": true }, "comment": { - "text": "The function name to call." + "text": "要调用的函数名." }, "type": { "type": "intrinsic", @@ -22693,7 +22693,7 @@ "isOptional": true }, "comment": { - "text": "The parameters to pass to the function call." + "text": "传递给函数调用的参数" }, "type": { "type": "union", @@ -22738,7 +22738,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法.\n" }, "sources": [ { @@ -27957,7 +27957,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法.\n" }, "sources": [ { @@ -27998,7 +27998,7 @@ "isExported": true }, "comment": { - "text": "If `true`, return the deleted row(s) in the response." + "text": "如果为`true`,则在响应中返回已删除的行。" }, "sources": [ { @@ -28096,7 +28096,7 @@ "isExported": true }, "comment": { - "text": "The values to insert." + "text": "插入的值." }, "type": { "type": "union", @@ -28581,7 +28581,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法\n" }, "sources": [ { @@ -29106,7 +29106,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table.\n" + "text": "用于对表中的行进行计数的计数算法.\n" }, "sources": [ { @@ -29245,7 +29245,7 @@ "isExported": true }, "comment": { - "text": "The values to insert." + "text": "插入的值." }, "type": { "type": "union", @@ -29305,7 +29305,7 @@ "isExported": true }, "comment": { - "text": "Count algorithm to use to count rows in a table." + "text": "用于对表中的行进行计数的计数算法." }, "sources": [ { @@ -29346,7 +29346,7 @@ "isExported": true }, "comment": { - "text": "Specifies if duplicate rows should be ignored and not inserted.\n" + "text": "指定重复行是否应忽略而不插入.\n" }, "sources": [ { @@ -29402,7 +29402,7 @@ "isExported": true }, "comment": { - "text": "By default the new record is returned. Set this to 'minimal' if you don't need this value." + "text": "默认情况下返回新记录。如果您不需要此值,请将其设置为‘minimal'" }, "sources": [ { diff --git a/web/spec/dart.yml b/web/spec/dart.yml index 67065ec4..f79f61fe 100644 --- a/web/spec/dart.yml +++ b/web/spec/dart.yml @@ -271,14 +271,14 @@ pages: select(): description: | - Performs vertical filtering with SELECT. - title: 'Fetch data: select()' + 使用 SELECT 执行垂直过滤。 + title: '获取 data: select()' notes: | - - By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed Project API Settings. It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data. - - `select()` can be combined with [Modifiers](/docs/reference/dart/using-modifiers) - - `select()` can be combined with [Filters](/docs/reference/dart/using-filters) + - 默认情况下,Supabase 项目将返回最多 1,000 行。此设置可以更改项目 API 设置。建议您将其保持在较低水平以限制意外或恶意请求的负载大小。您可以使用range()查询对数据进行分页。 + - `select()` 可以和 [Modifiers](/docs/reference/javascript/using-modifiers) 搭配使用 + - `select()` 可以和 [Filters](/docs/reference/javascript/using-filters) 搭配使用 examples: - - name: Getting your data + - name: 获取您的数据 isSpotlight: true dart: | ```dart @@ -290,8 +290,8 @@ pages: final data = res.data; final error = res.error; ``` - - name: Selecting specific columns - description: You can select specific fields from your tables. + - name: 选择特定的列 + description: 您可以从表格中选择特定字段. dart: | ```dart final res = await supabase @@ -299,8 +299,8 @@ pages: .select('name') .execute(); ``` - - name: Query foreign tables - description: If your database has relationships, you can query related tables too. + - name: 查询外部表 + description: 如果您的数据库表有关联,也可以查询其相关联的表 dart: | ```dart final res = await supabase @@ -313,14 +313,9 @@ pages: ''') .execute(); ``` - - name: Query the same foreign table multiple times + - name: 多次查询同一个外部表 description: | - Sometimes you will need to query the same foreign table twice. - In this case, you can use the name of the joined column to identify - which join you intend to use. For convenience, you can also give an - alias for each column. For example, if we had a shop of products, - and we wanted to get the supplier and the purchaser at the same time - (both in the users) table: + 有时您需要查询同一个外部表两次。在这种情况下,您可以使用连接列的名称来确定您打算使用哪个连接。为方便起见,您还可以为每一列指定别名。例如,如果我们有一个产品商店,并且我们想同时获取供应商和购买者(都在用户表中):: dart: | ```dart final res = await supabase @@ -332,10 +327,10 @@ pages: ''') .execute(); ``` - - name: Querying with count option + - name: 使用 count 选项查询 description: | - You can get the number of rows by using the count option. - Allowed values for count option are [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count). + 您可以使用 count 选项获取行数。 + 计数选项的允许值为 `null`, [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) 和 [estimated](https://postgrest.org/en/stable/api.html#estimated-count). dart: | ```dart final res = await supabase @@ -345,13 +340,11 @@ pages: final count = res.count; ``` - - name: Querying JSON data + - name: 查询json数据 description: | - If you have data inside of a JSONB column, you can apply select - and query filters to the data values. Postgres offers a - [number of operators](https://www.postgresql.org/docs/current/functions-json.html) - for querying JSON data. Also see - [PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details. + 如果 JSONB 列中有数据,则可以对数据值应用选择和查询过滤器。Postgres 提供了许多 + 用于查询 JSON 数据的[运算符](https://www.postgresql.org/docs/current/functions-json.html). 另请参阅 + [PostgREST 文档](http://postgrest.org/en/v7.0.0/api.html#json-columns)以获取更多详细信息。 dart: | ```dart final res = await supabase @@ -363,9 +356,9 @@ pages: .eq('address->postcode', 90210) .execute(); ``` - - name: Return data as CSV + - name: 以 CSV 格式返回数据 description: | - By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values. + 默认情况下,数据以 JSON 格式返回,但您也可以请求将其作为逗号分隔值返回。 dart: | ```dart fianl res = await supabase @@ -377,14 +370,12 @@ pages: insert(): description: | - Performs an INSERT into the table. - title: 'Create data: insert()' + 对表执行 INSERT. + title: '创建数据: insert()' notes: | - - By default, every time you run `insert()`, the client library will make a `select` to return the full record. - This is convenient, but it can also cause problems if your Policies are not configured to allow the `select` operation. - If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `minimal`. + - 默认情况下,每次运行时insert(),客户端库都会生成一个select以返回完整记录。这很方便,但如果您的策略未配置为允许select操作,它也会导致问题。如果您正在使用行级安全性并且遇到问题,请尝试将returning参数设置为minimal。 examples: - - name: Create a record + - name: 创建记录 isSpotlight: true dart: | ```dart @@ -394,7 +385,7 @@ pages: {'name': 'The Shire', 'country_id': 554} ]).execute(); ``` - - name: Bulk create + - name: 批量创建 dart: | ```dart final res = await supabase @@ -407,13 +398,13 @@ pages: update(): description: | - Performs an UPDATE on the table. - title: 'Modify data: update()' + 对表执行 UPDATE . + title: '修改数据: update()' notes: | - TODO update the link to dart - - `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update. + TODO 更新 dart 的链接 + - `update()` 应该和 [Filters](/docs/reference/javascript/using-filters) 搭配使用来定位您想更新的选项. examples: - - name: Updating your data + - name: 更新您的数据 isSpotlight: true dart: | ```dart @@ -423,12 +414,9 @@ pages: .match({ 'name': 'Auckland' }) .execute(); ``` - - name: Updating JSON data + - name: 更新JSON数据 description: | - Postgres offers a - [number of operators](https://www.postgresql.org/docs/current/functions-json.html) - for working with JSON data. Right now it is only possible to update an entire JSON document, - but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys. + Postgres 提供了 许多 用于处理 JSON 数据的[运算符](https://www.postgresql.org/docs/current/functions-json.html). 目前只能更新整个 JSON 文档,但我们正在研究如何更新单个关键字。 dart: | ```dart final res = await supabase @@ -445,13 +433,13 @@ pages: upsert(): description: | - Performs an UPSERT into the table. - title: 'Upsert data: upsert()' + 对表执行UPSERT. + title: '插入更新 数据: upsert()' notes: | - - Primary keys should to be included in the data payload in order for an update to work correctly. - - Primary keys must be natural, not surrogate. There are however, [workarounds](https://github.com/PostgREST/postgrest/issues/1118) for surrogate primary keys. + - 主键应包含在数据负载中,以便更新正常工作。 + - 主键必须是自然主键,而不是代理主键。但是,代理主键有一些[变通方法](https://github.com/PostgREST/postgrest/issues/1118). examples: - - name: Upsert your data + - name: Upsert您的数据 isSpotlight: true dart: | ```dart @@ -460,11 +448,9 @@ pages: .upsert({ 'id': 3, 'message': 'foo', 'username': 'supabot' }) .execute(); ``` - - name: Upserting into tables with constraints + - name: 插入有约束的表 description: | - Running the following will cause supabase to upsert data into the `users` table. - If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row - based on the column passed into `onConflict`. + 行以下命令将导致 supabase 将数据更新插入users表中。如果用户名 'supabot' 已经存在,则onConflict参数告诉 supabase 使用onConflict列传入的值覆盖该行。 isSpotlight: true dart: | ```dart @@ -473,7 +459,7 @@ pages: .upsert({ 'username': 'supabot' }, { 'onConflict': 'username' }) .execute(); ``` - - name: Return the exact number of rows + - name: 返回确切的行数 description: | Allowed values for count option are `exact`, `planned` and `estimated`. dart: | @@ -490,13 +476,15 @@ pages: delete(): description: | - Performs a DELETE on the table. - title: 'Delete data: delete()' + 对边执行DELETE. + title: '删除数据: delete()' notes: | - TODO update link to dart - - `delete()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete. + TODO 更新dart链接 + - `delete()` 应始终与[过滤器](/docs/reference/javascript/using-filters) 结合使用以定位您要删除的选项. + - 如果您使用delete()过滤器并且 启用了 + [RLS](/docs/learn/auth-deep-dive/auth-row-level-security) , 则只会删除通过`SELECT`策略可见的行。请注意,默认情况下没有行可见,因此您至少需要一个SELECT/ALL策略使行可见。 examples: - - name: Delete records + - name: 删除记录 isSpotlight: true dart: | ```dart @@ -508,33 +496,31 @@ pages: ``` rpc(): - title: 'Stored Procedures: rpc()' + title: '存储函数: rpc()' description: | - You can call stored procedures as a "Remote Procedure Call". + 您可以将 存储函数称为“远程过程调用”。 - That's a fancy way of saying that you can put some logic into your database then call it from anywhere. - It's especially useful when the logic rarely changes - like password resets and updates. + 这是一种奇特的说法,您可以将一些逻辑放入数据库中,然后从任何地方调用它。当逻辑很少改变时,它特别有用——比如密码重置和更新。 examples: - - name: Call a stored procedure + - name: 调用存储函数 isSpotlight: true - description: This is an example invoking a stored procedure. + description: 这是调用 Postgres 函数的示例 dart: | ```dart final res = await supabase .rpc('hello_world') .execute(); ``` - - name: With Parameters + - name: 带参数 dart: | ```dart final res = await supabase .rpc('echo_city', params: { 'name': 'The Shire' }) .execute(); ``` - - name: With count option + - name: 带 count 选项 description: | - You can specify a count option to get the row count along with your data. - Allowed values for count option are `exact`, `planned` and `estimated`. + 您可以指定一个计数选项来获取行计数以及您的数据。对于count选项允许值是 `null`, `exact`, `planned` and `estimated`. dart: | ```dart final res = await supabase diff --git a/web/spec/supabase.yml b/web/spec/supabase.yml index b15f6802..1f8981a2 100644 --- a/web/spec/supabase.yml +++ b/web/spec/supabase.yml @@ -419,14 +419,14 @@ pages: ``` select(): - title: 'Fetch data: select()' + title: '获取数据: select()' $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.select' notes: | - - By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed Project API Settings. It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data. - - `select()` can be combined with [Modifiers](/docs/reference/javascript/using-modifiers) - - `select()` can be combined with [Filters](/docs/reference/javascript/using-filters) + - 默认情况下,Supabase 项目将返回最多 1,000 行。此设置可以更改项目 API 设置。建议您将其保持在较低水平以限制意外或恶意请求的负载大小。您可以使用range()查询对数据进行分页。 + - `select()` 可以和 [Modifiers](/docs/reference/javascript/using-modifiers) 搭配使用 + - `select()` 可以和 [Filters](/docs/reference/javascript/using-filters) 搭配使用 examples: - - name: Getting your data + - name: 获取您的数据 isSpotlight: true js: | ```js @@ -434,16 +434,16 @@ pages: .from('cities') .select() ``` - - name: Selecting specific columns - description: You can select specific fields from your tables. + - name: 选择特定的列 + description: 您可以从表格中选择特定字段. js: | ```js const { data, error } = await supabase .from('cities') .select('name') ``` - - name: Query foreign tables - description: If your database has relationships, you can query related tables too. + - name: 查询外部表 + description: 如果您的数据库表有关联,也可以查询其相关联的表 js: | ```js const { data, error } = await supabase @@ -455,14 +455,9 @@ pages: ) `) ``` - - name: Query the same foreign table multiple times + - name: 多次查询同一个外部表 description: | - Sometimes you will need to query the same foreign table twice. - In this case, you can use the name of the joined column to identify - which join you intend to use. For convenience, you can also give an - alias for each column. For example, if we had a shop of products, - and we wanted to get the supplier and the purchaser at the same time - (both in the users) table: + 有时您需要查询同一个外部表两次。在这种情况下,您可以使用连接列的名称来确定您打算使用哪个连接。为方便起见,您还可以为每一列指定别名。例如,如果我们有一个产品商店,并且我们想同时获取供应商和购买者(都在用户表中):: js: | ```js const { data, error } = await supabase @@ -473,24 +468,21 @@ pages: purchaser:purchaser_id ( name ) `) ``` - - name: Querying with count option + - name: 使用 count 选项查询 description: | - You can get the number of rows by using the count option. - Allowed values for count option are `null`, [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count). + 您可以使用 count 选项获取行数。 + 计数选项的允许值为 `null`, [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) 和 [estimated](https://postgrest.org/en/stable/api.html#estimated-count). js: | ```js const { data, error, count } = await supabase .from('cities') .select('name', { count: 'exact' }) // if you don't want to return any rows, you can use { count: 'exact', head: true } ``` - - name: Querying JSON data + - name: 查询json数据 description: | - If you have data inside of a JSONB column, you can apply select - and query filters to the data values. Postgres offers a - [number of operators](https://www.postgresql.org/docs/current/functions-json.html) - for querying JSON data. Also see - [PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details. - js: | + 如果 JSONB 列中有数据,则可以对数据值应用选择和查询过滤器。Postgres 提供了许多 + 用于查询 JSON 数据的[运算符](https://www.postgresql.org/docs/current/functions-json.html). 另请参阅 + [PostgREST 文档](http://postgrest.org/en/v7.0.0/api.html#json-columns)以获取更多详细信息。 ```js const { data, error } = await supabase .from('users') @@ -500,9 +492,9 @@ pages: `) .eq('address->postcode', 90210) ``` - - name: Return data as CSV + - name: 以 CSV 格式返回数据 description: | - By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values. + 默认情况下,数据以 JSON 格式返回,但您也可以请求将其作为逗号分隔值返回。 js: | ```js const { data, error } = await supabase @@ -512,14 +504,12 @@ pages: ``` insert(): - title: 'Create data: insert()' + title: '创建数据: insert()' $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.insert' notes: | - - By default, every time you run `insert()`, the client library will make a `select` to return the full record. - This is convenient, but it can also cause problems if your Policies are not configured to allow the `select` operation. - If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `minimal`. + - 默认情况下,每次运行时insert(),客户端库都会生成一个select以返回完整记录。这很方便,但如果您的策略未配置为允许select操作,它也会导致问题。如果您正在使用行级安全性并且遇到问题,请尝试将returning参数设置为minimal。 examples: - - name: Create a record + - name: 创建记录 isSpotlight: true js: | ```js @@ -529,7 +519,7 @@ pages: { name: 'The Shire', country_id: 554 } ]) ``` - - name: Bulk create + - name: 批量创建 js: | ```js const { data, error } = await supabase @@ -539,13 +529,9 @@ pages: { name: 'Rohan', country_id: 555 }, ]) ``` - - name: Upsert + - name: upsert description: | - For upsert, if set to true, primary key columns would need to be included - in the data parameter in order for an update to properly happen. Also, primary keys - used must be natural, not surrogate. There are however, - [workarounds](https://github.com/PostgREST/postgrest/issues/1118) - for surrogate primary keys. + 对于 upsert,如果设置为 true,则需要将主键列包含在数据参数中,以便正确进行更新。此外,使用的主键必须是自然主键,但是, 代理主键有一些[变通方法](https://github.com/PostgREST/postgrest/issues/1118)。 js: | ```js const { data, error } = await supabase @@ -560,12 +546,12 @@ pages: ``` update(): - title: 'Modify data: update()' + title: '修改数据: update()' $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.update' notes: | - - `update()` should always be combined with [Filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to update. + - `update()` 应该和 [Filters](/docs/reference/javascript/using-filters) 搭配使用来定位您想更新的选项. examples: - - name: Updating your data + - name: 更新您的数据 isSpotlight: true js: | ```js @@ -574,12 +560,9 @@ pages: .update({ name: 'Middle Earth' }) .match({ name: 'Auckland' }) ``` - - name: Updating JSON data + - name: 更新JSON数据 description: | - Postgres offers a - [number of operators](https://www.postgresql.org/docs/current/functions-json.html) - for working with JSON data. Right now it is only possible to update an entire JSON document, - but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys. + Postgres 提供了 许多 用于处理 JSON 数据的[运算符](https://www.postgresql.org/docs/current/functions-json.html). 目前只能更新整个 JSON 文档,但我们正在研究如何更新单个关键字。 js: | ```js const { data, error } = await supabase @@ -594,13 +577,13 @@ pages: ``` upsert(): - title: 'Upsert data: upsert()' + title: '插入更新 数据: upsert()' $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.upsert' notes: | - - Primary keys should to be included in the data payload in order for an update to work correctly. - - Primary keys must be natural, not surrogate. There are however, [workarounds](https://github.com/PostgREST/postgrest/issues/1118) for surrogate primary keys. + - 主键应包含在数据负载中,以便更新正常工作。 + - 主键必须是自然主键,而不是代理主键。但是,代理主键有一些[变通方法](https://github.com/PostgREST/postgrest/issues/1118). examples: - - name: Upsert your data + - name: Upsert您的数据 isSpotlight: true js: | ```js @@ -608,7 +591,7 @@ pages: .from('messages') .upsert({ id: 3, message: 'foo', username: 'supabot' }) ``` - - name: Bulk Upsert your data + - name: 批量Upsert您的数据 isSpotlight: false js: | ```js @@ -619,11 +602,9 @@ pages: { id: 4, message: 'bar', username: 'supabot' } ]) ``` - - name: Upserting into tables with constraints + - name: 插入有约束的表 description: | - Running the following will cause supabase to upsert data into the `users` table. - If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row - based on the column passed into `onConflict`. + 行以下命令将导致 supabase 将数据更新插入users表中。如果用户名 'supabot' 已经存在,则onConflict参数告诉 supabase 使用onConflict列传入的值覆盖该行。 isSpotlight: true js: | ```js @@ -631,7 +612,7 @@ pages: .from('users') .upsert({ username: 'supabot' }, { onConflict: 'username' }) ``` - - name: Return the exact number of rows + - name: 返回确切的行数 isSpotlight: true js: | ```js @@ -646,17 +627,14 @@ pages: ``` delete(): - title: 'Delete data: delete()' + title: '删除数据: delete()' $ref: '@supabase/postgrest-js."lib/PostgrestQueryBuilder".PostgrestQueryBuilder.delete' notes: | - - `delete()` should always be combined with [filters](/docs/reference/javascript/using-filters) to target the item(s) you wish to delete. - - If you use `delete()` with filters and you have - [RLS](/docs/learn/auth-deep-dive/auth-row-level-security) enabled, only - rows visible through `SELECT` policies are deleted. Note that by default - no rows are visible, so you need at least one `SELECT`/`ALL` policy that - makes the rows visible. + - `delete()` 应始终与[过滤器](/docs/reference/javascript/using-filters) 结合使用以定位您要删除的选项. + - 如果您使用delete()过滤器并且 启用了 + [RLS](/docs/learn/auth-deep-dive/auth-row-level-security) , 则只会删除通过`SELECT`策略可见的行。请注意,默认情况下没有行可见,因此您至少需要一个SELECT/ALL策略使行可见。 examples: - - name: Delete records + - name: 删除记录 isSpotlight: true js: | ```js @@ -667,40 +645,39 @@ pages: ``` rpc(): - title: 'Postgres functions: rpc()' + title: 'Postgres 函数: rpc()' description: | - You can call Postgres functions as a "Remote Procedure Call". + 您可以将 Postgres 函数称为“远程过程调用”。 - That's a fancy way of saying that you can put some logic into your database then call it from anywhere. - It's especially useful when the logic rarely changes - like password resets and updates. + 这是一种奇特的说法,您可以将一些逻辑放入数据库中,然后从任何地方调用它。当逻辑很少改变时,它特别有用——比如密码重置和更新。 $ref: '@supabase/postgrest-js."PostgrestClient".PostgrestClient.rpc' examples: - - name: Call a Postgres function + - name: 调用 Postgres 函数 isSpotlight: true - description: This is an example invoking a Postgres function. + description: 这是调用 Postgres 函数的示例 js: | ```js const { data, error } = await supabase .rpc('hello_world') ``` - - name: With Parameters + - name: 带参数 js: | ```js const { data, error } = await supabase .rpc('echo_city', { name: 'The Shire' }) ``` - - name: Bulk processing - description: You can process large payloads at once using [array parameters](https://postgrest.org/en/stable/api.html#calling-functions-with-array-parameters). + - name: 批量处理 + description: 您可以使用[数组参数](https://postgrest.org/en/stable/api.html#calling-functions-with-array-parameters)一次处理大型负载. js: | ```js const { data, error } = await postgrest .rpc('echo_cities', { names: ['The Shire', 'Mordor'] }) ``` - - name: With filters + - name: 带过滤器 description: | - Postgres functions that return tables can also be combined with - [Modifiers](/docs/reference/javascript/using-modifiers) and - [Filters](/docs/reference/javascript/using-filters). + 返回表的 Postgres 函数也可以与 + [Modifiers](/docs/reference/javascript/using-modifiers) 和 + [Filters](/docs/reference/javascript/using-filters)结合使用. js: | ```js const { data, error } = await supabase @@ -708,10 +685,9 @@ pages: .select('name, population') .eq('name', 'The Shire') ``` - - name: With count option + - name: 带 count 选项 description: | - You can specify a count option to get the row count along with your data. - Allowed values for count option are `null`, `exact`, `planned` and `estimated`. + 您可以指定一个计数选项来获取行计数以及您的数据。对于count选项允许值是 `null`, `exact`, `planned` and `estimated`. js: | ```js const { data, error, count } = await supabase -- Gitee