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: docs/content/stable/develop/drivers-orms/nodejs/sequelize.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,29 @@ The following code creates an Employees model to store and retrieve employee inf
88
88
- The actual table is created by calling the `Employee.sync()` API in the `createTableAndInsert()` function. This also inserts the data for three employees into the table using the `Employee.create()` API.
89
89
- Finally, you can retrieve the information of all employees using `Employee.findAll()`.
90
90
91
+
#### Using the YugabyteDB Smart Driver
92
+
93
+
You can also use the YugabyteDB smart driver (`@yugabytedb/pg`) which provides connection load balancing feature that spreads connections uniformly across the nodes in the entire cluster or in specific placements (zones or regions).
94
+
95
+
Read more on the smart driver features [here](../../smart-drivers/#using-yugabytedb-smart-drivers).
96
+
97
+
To use the YugabyteDB smart driver instead of the vanilla PG driver, add the following to your application's `package.json` dependencies:
98
+
99
+
```json
100
+
{
101
+
"dependencies": {
102
+
"sequelize-yugabytedb": "^1.0.5",
103
+
"pg": "npm:@yugabytedb/pg@8.7.3-yb-10"
104
+
}
105
+
}
106
+
```
107
+
108
+
This overrides the default PostgreSQL driver with the YugabyteDB smart driver.
109
+
110
+
To provide the load-balance specific properties, use either the environment variables or connection parameters. See the examples below for more details.
111
+
112
+
For a complete working example, refer to the [Sequelize ORM example application](https://github.com/YugabyteDB-Samples/orm-examples/tree/master/node/sequelize).
113
+
91
114
Add the code in the `example.js` file.
92
115
93
116
```js
@@ -189,6 +212,59 @@ Employees Details:
189
212
]
190
213
```
191
214
215
+
#### Specifying load balance properties
216
+
217
+
You can enable these features by specifying the properties either as the environment variables or via connection parameters.
0 commit comments