Skip to content

Commit 451d262

Browse files
committed
update again!
1 parent 2f49eeb commit 451d262

File tree

8 files changed

+72
-56
lines changed

8 files changed

+72
-56
lines changed

docs/reference/globals.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
4646
### Example
4747

4848
```js
49-
const ProductTable = tables.Product; // Same as databases.data.Product
49+
const Product = tables.Product; // Same as databases.data.Product
5050

5151
// Create a new record (`id` is automatically generated when using `.create()`)
52-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
52+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
53+
54+
// Modify the record
55+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
5356

5457
// Retrieve by primary key
55-
const record = await ProductTable.get(created.id);
58+
const record = await Product.get(created.id);
5659

57-
// Insert or replace by ID
58-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
60+
logger.info('New price:', record.price);
5961

6062
// Query for all products with a `price` less than `8.00`
6163
const query = {
6264
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
6365
};
6466

65-
for await (const record of ProductTable.search(query)) {
66-
// Handle each row
67+
for await (const record of Product.search(query)) {
68+
// ...
6769
}
6870
```
6971

docs/reference/resources/index.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
104104
#### Example
105105

106106
```js
107-
const ProductTable = tables.Product; // Same as databases.data.Product
107+
const Product = tables.Product; // Same as databases.data.Product
108108

109109
// Create a new record (`id` is automatically generated when using `.create()`)
110-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
110+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
111+
112+
// Modify the record
113+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
111114

112115
// Retrieve by primary key
113-
const record = await ProductTable.get(created.id);
116+
const record = await Product.get(created.id);
114117

115-
// Insert or replace by ID
116-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
118+
logger.info('New price:', record.price);
117119

118120
// Query for all products with a `price` less than `8.00`
119121
const query = {
120122
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
121123
};
122124

123-
for await (const record of ProductTable.search(query)) {
124-
// Handle each row
125+
for await (const record of Product.search(query)) {
126+
// ...
125127
}
126128
```
127129

versioned_docs/version-4.5/reference/globals.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
4646
### Example
4747

4848
```js
49-
const ProductTable = tables.Product; // Same as databases.data.Product
49+
const Product = tables.Product; // Same as databases.data.Product
5050

5151
// Create a new record (`id` is automatically generated when using `.create()`)
52-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
52+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
53+
54+
// Modify the record
55+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
5356

5457
// Retrieve by primary key
55-
const record = await ProductTable.get(created.id);
58+
const record = await Product.get(created.id);
5659

57-
// Insert or replace by ID
58-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
60+
logger.info('New price:', record.price);
5961

6062
// Query for all products with a `price` less than `8.00`
6163
const query = {
6264
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
6365
};
6466

65-
for await (const record of ProductTable.search(query)) {
66-
// Handle each row
67+
for await (const record of Product.search(query)) {
68+
// ...
6769
}
6870
```
6971

versioned_docs/version-4.5/reference/resource.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
103103
#### Example
104104

105105
```js
106-
const ProductTable = tables.Product; // Same as databases.data.Product
106+
const Product = tables.Product; // Same as databases.data.Product
107107

108108
// Create a new record (`id` is automatically generated when using `.create()`)
109-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
109+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
110+
111+
// Modify the record
112+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
110113

111114
// Retrieve by primary key
112-
const record = await ProductTable.get(created.id);
115+
const record = await Product.get(created.id);
113116

114-
// Insert or replace by ID
115-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
117+
logger.info('New price:', record.price);
116118

117119
// Query for all products with a `price` less than `8.00`
118120
const query = {
119121
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
120122
};
121123

122-
for await (const record of ProductTable.search(query)) {
123-
// Handle each row
124+
for await (const record of Product.search(query)) {
125+
// ...
124126
}
125127
```
126128

versioned_docs/version-4.6/reference/globals.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
4646
### Example
4747

4848
```js
49-
const ProductTable = tables.Product; // Same as databases.data.Product
49+
const Product = tables.Product; // Same as databases.data.Product
5050

5151
// Create a new record (`id` is automatically generated when using `.create()`)
52-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
52+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
53+
54+
// Modify the record
55+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
5356

5457
// Retrieve by primary key
55-
const record = await ProductTable.get(created.id);
58+
const record = await Product.get(created.id);
5659

57-
// Insert or replace by ID
58-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
60+
logger.info('New price:', record.price);
5961

6062
// Query for all products with a `price` less than `8.00`
6163
const query = {
6264
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
6365
};
6466

65-
for await (const record of ProductTable.search(query)) {
66-
// Handle each row
67+
for await (const record of Product.search(query)) {
68+
// ...
6769
}
6870
```
6971

versioned_docs/version-4.6/reference/resources/index.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
104104
#### Example
105105

106106
```js
107-
const ProductTable = tables.Product; // Same as databases.data.Product
107+
const Product = tables.Product; // Same as databases.data.Product
108108

109109
// Create a new record (`id` is automatically generated when using `.create()`)
110-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
110+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
111+
112+
// Modify the record
113+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
111114

112115
// Retrieve by primary key
113-
const record = await ProductTable.get(created.id);
116+
const record = await Product.get(created.id);
114117

115-
// Insert or replace by ID
116-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
118+
logger.info('New price:', record.price);
117119

118120
// Query for all products with a `price` less than `8.00`
119121
const query = {
120122
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
121123
};
122124

123-
for await (const record of ProductTable.search(query)) {
124-
// Handle each row
125+
for await (const record of Product.search(query)) {
126+
// ...
125127
}
126128
```
127129

versioned_docs/version-4.7/reference/globals.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
4646
### Example
4747

4848
```js
49-
const ProductTable = tables.Product; // Same as databases.data.Product
49+
const Product = tables.Product; // Same as databases.data.Product
5050

5151
// Create a new record (`id` is automatically generated when using `.create()`)
52-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
52+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
53+
54+
// Modify the record
55+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
5356

5457
// Retrieve by primary key
55-
const record = await ProductTable.get(created.id);
58+
const record = await Product.get(created.id);
5659

57-
// Insert or replace by ID
58-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
60+
logger.info('New price:', record.price);
5961

6062
// Query for all products with a `price` less than `8.00`
6163
const query = {
6264
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
6365
};
6466

65-
for await (const record of ProductTable.search(query)) {
66-
// Handle each row
67+
for await (const record of Product.search(query)) {
68+
// ...
6769
}
6870
```
6971

versioned_docs/version-4.7/reference/resources/index.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,26 @@ Once declared, `Product` will be available as `tables.Product` (or `databases.da
104104
#### Example
105105

106106
```js
107-
const ProductTable = tables.Product; // Same as databases.data.Product
107+
const Product = tables.Product; // Same as databases.data.Product
108108

109109
// Create a new record (`id` is automatically generated when using `.create()`)
110-
const created = await ProductTable.create({ name: 'Shirt', price: 9.5 });
110+
const created = await Product.create({ name: 'Shirt', price: 9.5 });
111+
112+
// Modify the record
113+
await Product.patch(created.id, { price: Math.round(created.price * 0.8 * 100) / 100 }); // 20% off!
111114

112115
// Retrieve by primary key
113-
const record = await ProductTable.get(created.id);
116+
const record = await Product.get(created.id);
114117

115-
// Insert or replace by ID
116-
await ProductTable.put({ id: record.id, name: record.name, price: 7.5 });
118+
logger.info('New price:', record.price);
117119

118120
// Query for all products with a `price` less than `8.00`
119121
const query = {
120122
conditions: [{ attribute: 'price', comparator: 'less_than', value: 8.0 }],
121123
};
122124

123-
for await (const record of ProductTable.search(query)) {
124-
// Handle each row
125+
for await (const record of Product.search(query)) {
126+
// ...
125127
}
126128
```
127129

0 commit comments

Comments
 (0)