Skip to content

Commit ae4b843

Browse files
authored
Editing ReadMe to remove catalog schema reference (#12)
1 parent 38be94e commit ae4b843

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

README.md

+16-17
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Step 1: Run `start_oss_server.sh` to initialize the DocumentDB server and manage
9191
Step 2: Connect to `psql` shell
9292

9393
```bash
94-
psql -p 9712 -h localhost -d postgres
94+
psql -p 9712 -d postgres
9595
```
9696

9797
## Usage
@@ -128,20 +128,19 @@ The `documentdb_api.collection` function is used for retrieving the documents in
128128
SELECT document FROM documentdb_api.collection('documentdb','patient');
129129
```
130130

131-
Alternatively, we can apply filter for specific condition using `@@` or `@=`
131+
Alternatively, we can apply filter to our queries.
132132

133133
```sql
134-
SET search_path TO documentdb_api, documentdb_api_catalog,documentdb_core;
134+
SET search_path TO documentdb_api, documentdb_core;
135135
SET documentdb_core.bsonUseEJson TO true;
136136

137-
SELECT document FROM documentdb_api.collection('documentdb','patient') WHERE document @@ '{"patient_id":"P005"}';
137+
SELECT cursorPage FROM documentdb_api.find_cursor_first_page('documentdb', '{ "find" : "patient", "filter" : {"patient_id":"P005"}}');
138138
```
139139

140140
We can perform range queries as well.
141141

142142
```sql
143-
SELECT document FROM documentdb_api.collection('documentdb','patient')
144-
WHERE document @@ '{ "$and": [{ "age": { "$gte": 10 } },{ "age": { "$lte": 35 } }] }';
143+
SELECT cursorPage FROM documentdb_api.find_cursor_first_page('documentdb', '{ "find" : "patient", "filter" : { "$and": [{ "age": { "$gte": 10 } },{ "age": { "$lte": 35 } }] }}');
145144
```
146145

147146
#### Update document in a collection
@@ -157,7 +156,7 @@ select documentdb_api.update('documentdb', '{"update":"patient", "updates":[{"q"
157156
Similarly, we can update multiple documents using `multi` property.
158157

159158
```sql
160-
SELECT documentdb_api.update('documentdb', '{"update":"patient", "updates":[{"q":{},"u":{"$set":{"age":50}},"multi":true}]}');
159+
SELECT documentdb_api.update('documentdb', '{"update":"patient", "updates":[{"q":{},"u":{"$set":{"age":24}},"multi":true}]}');
161160
```
162161

163162
#### Delete document from the collection
@@ -172,16 +171,16 @@ SELECT documentdb_api.delete('documentdb', '{"delete": "patient", "deletes": [{"
172171

173172
### Collection management
174173

175-
We can review for the available collections and databases by querying `documentdb_api_catalog.collections`.
174+
We can review for the available collections and databases by querying [documentdb_api.list_collections_cursor_first_page](https://github.com/microsoft/documentdb/wiki/Functions#list_collections_cursor_first_page).
176175

177176
```sql
178-
SELECT * FROM documentdb_api_catalog.collections;
177+
SELECT * FROM documentdb_api.list_collections_cursor_first_page('documentdb', '{ "listCollections": 1 }');
179178
```
180179

181-
`documentdb_api_catalog.collection_indexes` allows reviewing for the existing indexes on a collection. We can find collection_id from `documentdb_api_catalog.collections`.
180+
[documentdb_api.list_indexes_cursor_first_page](https://github.com/microsoft/documentdb/wiki/Functions#list_indexes_cursor_first_page) allows reviewing for the existing indexes on a collection. We can find collection_id from `documentdb_api.list_collections_cursor_first_page`.
182181

183182
```sql
184-
SELECT * FROM documentdb_api_catalog.collection_indexes WHERE collection_id = 2;
183+
SELECT documentdb_api.list_indexes_cursor_first_page('documentdb','{"listIndexes": "patient"}');
185184
```
186185

187186
`ttl` indexes by default gets scheduled through the `pg_cron` scheduler, which could be reviewed by querying the `cron.job` table.
@@ -210,33 +209,33 @@ SELECT * FROM documentdb_api.create_indexes_background('documentdb', '{ "createI
210209

211210
#### Drop an Index
212211

213-
`DocumentDB` uses the `documentdb_api.drop_indexes` function, which allows you to remove an existing index from a collection. The SQL command demonstrates how to drop the index named `id_ab_1` from the `first_collection` collection of the `documentdb`.
212+
DocumentDB uses the `documentdb_api.drop_indexes` function, which allows you to remove an existing index from a collection. The SQL command demonstrates how to drop the index named `id_ab_1` from the `first_collection` collection of the `documentdb`.
214213

215214
```sql
216215
CALL documentdb_api.drop_indexes('documentdb', '{"dropIndexes": "patient", "index":"idx_age"}');
217216
```
218217

219218
### Perform aggregations `Group by`
220219

221-
DocumentDB provides the `documentdb_api_catalog.bson_aggregation_pipeline` function, for performing aggregations over the document store.
220+
DocumentDB provides the [documentdb_api.aggregate_cursor_first_page](https://github.com/microsoft/documentdb/wiki/Functions#aggregate_cursor_first_page) function, for performing aggregations over the document store.
222221

223222
The example projects an aggregation on number of patients registered over the years.
224223

225224
```sql
226-
SELECT document FROM documentdb_api_catalog.bson_aggregation_pipeline('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$group": { "_id": "$registration_year", "count_patients": { "$count": {} } } } ] }');
225+
SELECT cursorpage FROM documentdb_api.aggregate_cursor_first_page('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$group": { "_id": "$registration_year", "count_patients": { "$count": {} } } } ] , "cursor": { "batchSize": 3 } }');
227226
```
228227

229228
We can perform more complex operations, listing below a few more usage examples.
230229
The example demonstrates an aggregation on patients, categorizing them into buckets defined by registration_year boundaries.
231230

232231
```sql
233-
SELECT document FROM bson_aggregation_pipeline('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$bucket": { "groupBy": "$registration_year", "boundaries": ["2022","2023","2024"], "default": "unknown" } } ] }');
232+
SELECT cursorpage FROM documentdb_api.aggregate_cursor_first_page('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$bucket": { "groupBy": "$registration_year", "boundaries": ["2022","2023","2024"], "default": "unknown" } } ], "cursor": { "batchSize": 3 } }');
234233
```
235234

236235
This query performs an aggregation on the `patient` collection to group documents by `registration_year`. It collects unique patient conditions for each registration year using the `$addToSet` operator.
237236

238237
```sql
239-
SELECT document FROM documentdb_api_catalog.bson_aggregation_pipeline('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$group": { "_id": "$registration_year", "conditions": { "$addToSet": { "conditions" : "$conditions" } } } } ] }');
238+
SELECT cursorpage FROM documentdb_api.aggregate_cursor_first_page('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$group": { "_id": "$registration_year", "conditions": { "$addToSet": { "conditions" : "$conditions" } } } } ], "cursor": { "batchSize": 3 } }');
240239
```
241240

242241
### Join data from multiple collections
@@ -255,7 +254,7 @@ select documentdb_api.insert_one('documentdb','appointment', '{ "appointment_id"
255254
The example presents each patient along with the doctors visited.
256255

257256
```sql
258-
SELECT document FROM documentdb_api_catalog.bson_aggregation_pipeline('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$lookup": { "from": "appointment","localField": "patient_id", "foreignField": "patient_id", "as": "appointment" } },{"$unwind":"$appointment"},{"$project":{"_id":0,"name":1,"appointment.doctor_name":1,"appointment.appointment_date":1}} ]}');
257+
SELECT cursorpage FROM documentdb_api.aggregate_cursor_first_page('documentdb', '{ "aggregate": "patient", "pipeline": [ { "$lookup": { "from": "appointment","localField": "patient_id", "foreignField": "patient_id", "as": "appointment" } },{"$unwind":"$appointment"},{"$project":{"_id":0,"name":1,"appointment.doctor_name":1,"appointment.appointment_date":1}} ], "cursor": { "batchSize": 3 } }');
259258
```
260259

261260
### Community

0 commit comments

Comments
 (0)