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
Use the [Data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html) to add a PostgreSQL data source to your application.
48
+
Use the [Data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html) to add a PostgreSQL data source to your application.
49
49
The generator will prompt for the database server hostname, port, and other settings
50
50
required to connect to a PostgreSQL database. It will also run the `npm install` command above for you.
51
51
@@ -96,7 +96,7 @@ const config = {
96
96
97
97
Check out [node-pg-pool](https://github.com/brianc/node-pg-pool) and [node postgres pooling example](https://github.com/brianc/node-postgres#pooling-example) for more information.
98
98
99
-
### Properties
99
+
### Configuration options
100
100
101
101
<table>
102
102
<thead>
@@ -106,7 +106,7 @@ Check out [node-pg-pool](https://github.com/brianc/node-pg-pool) and [node postg
106
106
<th>Description</th>
107
107
</tr>
108
108
</thead>
109
-
<tbody>
109
+
<tbody>
110
110
<tr>
111
111
<td>connector</td>
112
112
<td>String</td>
@@ -176,6 +176,14 @@ Check out [node-pg-pool](https://github.com/brianc/node-pg-pool) and [node postg
176
176
<td>Boolean/String</td>
177
177
<td>Set to <code>false</code> to disable default sorting on <code>id</code> column(s). Set to <code>numericIdOnly</code> to only apply to IDs with a number type <code>id</code>.</td>
178
178
</tr>
179
+
<tr>
180
+
<td>allowExtendedOperators</td>
181
+
<td>Boolean</td>
182
+
<td>Set to <code>true</code> to enable PostgreSQL-specific operators
**Note** The fields you are querying must be setup to use the postgresql array data type - see [Defining models](#defining-models) above.
567
+
568
+
Assuming a model such as this:
569
+
570
+
```ts
571
+
@model({
572
+
settings: {
573
+
allowExtendedOperators:true,
574
+
}
575
+
})
576
+
classPost {
577
+
@property({
578
+
type: ['string'],
579
+
postgresql: {
580
+
dataType:'varchar[]',
581
+
},
582
+
})
583
+
categories?: string[];
584
+
}
585
+
```
586
+
587
+
You can query the tags fields as follows:
588
+
589
+
```ts
590
+
constposts=awaitpostRepository.find({
591
+
where: {
592
+
{
593
+
categories: {'contains': ['AA']},
594
+
}
595
+
}
596
+
});
597
+
```
598
+
534
599
## Discovery and auto-migration
535
600
536
601
### Model discovery
537
602
538
603
The PostgreSQL connector supports _model discovery_ that enables you to create LoopBack models
539
604
based on an existing database schema. Once you defined your datasource:
540
-
- LoopBack 4 users could use the commend [`lb4 discover`](https://loopback.io/doc/en/lb4/Discovering-models.html) to discover models.
541
-
- For LB3 users, please check [Discovering models from relational databases](https://loopback.io/doc/en/lb3/Discovering-models-from-relational-databases.html).
605
+
- LoopBack 4 users could use the commend [`lb4 discover`](https://loopback.io/doc/en/lb4/Discovering-models.html) to discover models.
606
+
- For LB3 users, please check [Discovering models from relational databases](https://loopback.io/doc/en/lb3/Discovering-models-from-relational-databases.html).
542
607
543
608
(See [database discovery API](http://apidocs.strongloop.com/loopback-datasource-juggler/#datasource-prototype-discoverandbuildmodels) for related APIs information)
544
609
@@ -612,7 +677,7 @@ Here are some limitations and tips:
612
677
613
678
### Auto-migrate/Auto-update models with foreign keys
614
679
615
-
Foreign key constraints can be defined in the model definition.
680
+
Foreign key constraints can be defined in the model definition.
616
681
617
682
**Note**: The order of table creation is important. A referenced table must exist before creating a foreign key constraint.
0 commit comments