You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/complete-mutation.md
+17-19Lines changed: 17 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,20 @@ postnumber: 17
10
10
11
11
Now we are going to complete the mutation. First off let's install some packages:
12
12
13
-
```
13
+
```javascript
14
14
$ yarn add uuid stripe
15
15
```
16
16
17
-
⌛ uuid is used to generate random UUID's for the bookingId. Since Dynamo is a NoSQL datastore it does not auto-generate IDs like a SQL datastore.
17
+
⌛ `uuid` is used to generate random UUID's for the `bookingId`. Since DynamoDB is a NoSQL datastore it does not auto-generate IDs like a SQL datastore.
18
18
19
-
⌛ stripe will allow us to interact with the stripe API.
19
+
⌛ `stripe` will allow us to interact with the stripe API.
20
20
21
-
Next lets go into our makeABooking mutation and add the following:
21
+
Next lets go into our `makeABooking` mutation and add the following:
22
22
23
-
```
24
-
import { v1 as uuidv1 } from "uuid";
25
-
import stripePackage from "stripe";
26
-
import * as dynamoDBLib from "../../libs/dynamodb-lib";
⌛ First off we are adding our necessary libs to the file
51
50
52
-
⌛ then we are creating a function called getPrices that will go into the listings table and get the listing that matches thee listingId for the listing the customer wants to make a booking for.
51
+
⌛ Then we are creating a function called `getPrices` that will go into the `listings` table and get the listing that matches the `listingId` for the listing the customer wants to make a booking for.
⌛ As before we are simply creating a params object that has the necessary TableName, and the fields that match the Booking Type in the schema. We have added a createdTimestamp and paymentDetails fields for internal use that will not be exposed to the API.
109
+
⌛ As before we are simply creating a `params` object that has the necessary `TableName`, and the fields that match the Booking Type in the schema. We have added a `createdTimestamp` and `paymentDetails` fields for internal use that will not be exposed to the API.
112
110
113
-
Next let's send the params to Dynamo:
111
+
Next let's send the params to DynamoDB:
114
112
115
113
```javascript
116
114
try {
@@ -138,7 +136,7 @@ try {
138
136
}
139
137
```
140
138
141
-
⌛ We are simply doing a put action to Dynamo to insert the mutation into the table.
139
+
⌛ We are simply doing a put action to DynamoDB to insert the mutation into the table.
142
140
143
141
⌛ Then we are returning the Booking object back to the API.
0 commit comments