|
1 | 1 | [](https://www.contentstack.com/)
|
2 |
| -## Contentstack Sync Mongodb SDK |
3 | 2 |
|
4 |
| -The Contentstack sync utility lets you sync your Contentstack data on your server, enabling you to save data locally and serve content directly from your server. |
| 3 | +Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/). |
5 | 4 |
|
6 |
| -The Cotentstack mongodb content store library is part of Contentstack sync utility's content storage drivers and is used to store data in the MongoDB database and [contentstack-sync-mongodb-sdk]() library is used to query data stored there. |
| 5 | +## Contentstack DataSync MongoDB SDK |
7 | 6 |
|
8 |
| -Learn how Contentstack helps you store your data locally with the help of the Contentstack sync utility [here](). |
9 |
| - |
10 |
| -Currently, Contentstack offers the following databases for storing the synced data: |
11 |
| -- Filesystem data store: [contentstack-content-store-filesystem](https://github.com/contentstack/contentstack-content-store-filesystem) used to store data in your system's filesystem. You can use filesystem SDK [contentstack-sync-filesystem-sdk]((https://github.com/contentstack/contentstack-sync-filesystem-sdk) to query data from filesystem. |
12 |
| -- Filesystem asset store: [contentstack-asset-store-filesystem](https://github.com/contentstack/contentstack-asset-store-filesystem) |
13 |
| -- Mongodb data store: [contentstack-content-store-mongodb](https://github.com/contentstack/contentstack-content-store-mongodb) used to store data in your MongoDB. You can use MongoDB SDK [contentstack-sync-mongodb-sdk]((https://github.com/contentstack/contentstack-sync-mongodb-sdk) to query data from mongodb. |
| 7 | +[Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync) provides MongoDB SDK to query applications that have locally stored contents in mongodb. Given below is the detailed guide and helpful resources to get started. |
14 | 8 |
|
15 | 9 | ### Prerequisite
|
16 | 10 |
|
17 | 11 | - nodejs, v8+
|
18 |
| -- Data synced via mongodb content store |
19 | 12 | - MongoDB, v3.6 or higher
|
| 13 | +- You should have the data synced through [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync) |
| 14 | + |
| 15 | +### Configuration |
| 16 | + |
| 17 | +|Property|Data Type|Default value|Description| |
| 18 | +|--|--|--|--| |
| 19 | +|dbName|string|contentstack-persistent-db|**Optional** The MongoDB database name| |
| 20 | +|collectionName|string|contents|**Optional** MongoDB database's collection name| |
| 21 | +|uri|string|mongodb://localhost:27017 |**Optional.** The MongoDB connection URI| |
| 22 | +| indexes | object |**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** Option to create db indexes via configuration| |
| 23 | +|projections|object|**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** Mongodb projections. Keys provided here would be displayed/filtered out when fetching the result| |
| 24 | +|options|object|**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** MongoDB connection options [Ref.](http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html) for more info| |
| 25 | +|limit|number|**Optional.** Caps the total no of objects returned in a single call| |
| 26 | +|skip|number|**Optional.** Number of objects skipped before the result is returned| |
| 27 | + |
| 28 | +### Detailed configs |
| 29 | + |
| 30 | +By default, this module uses the following internal configuration. |
| 31 | + |
| 32 | +```js |
| 33 | +{ |
| 34 | + dbName: 'contentstack-persistent-db', |
| 35 | + collectionName: 'contents', |
| 36 | + uri: 'mongodb://localhost:27017', |
| 37 | + indexes: { |
| 38 | + published_at: -1, |
| 39 | + content_type_uid: 1, |
| 40 | + locale: 1, |
| 41 | + uid: 1 |
| 42 | + }, |
| 43 | + limit: 100, |
| 44 | + locales: [ |
| 45 | + ], |
| 46 | + options: { |
| 47 | + autoReconnect: true, |
| 48 | + connectTimeoutMS: 15000, |
| 49 | + keepAlive: true, |
| 50 | + noDelay: true, |
| 51 | + reconnectInterval: 1000, |
| 52 | + reconnectTries: 20, |
| 53 | + useNewUrlParser: true, |
| 54 | + }, |
| 55 | + projections: { |
| 56 | + _id: 0, |
| 57 | + _version: 0, |
| 58 | + content_type_uid: 0, |
| 59 | + created_at: 0, |
| 60 | + sys_keys: 0, |
| 61 | + updated_at: 0, |
| 62 | + updated_by: 0, |
| 63 | + }, |
| 64 | + skip: 0, |
| 65 | +} |
| 66 | +``` |
20 | 67 |
|
21 | 68 | ### Setup and Installation
|
22 | 69 |
|
@@ -110,4 +157,22 @@ Once you have initialized the SDK, you can start querying on the sync-utility's
|
110 | 157 | })
|
111 | 158 | .catch(reject)
|
112 | 159 | ```
|
113 |
| -For more details on queries supported/querying, [refer this](./mongodb-sdk-querying.md)! |
| 160 | + |
| 161 | +## Advanced Queries |
| 162 | + |
| 163 | +In order to learn more about advance queries please refer the API documentation, [here](https://contentstack.github.io/datasync-mongodb-sdk/). |
| 164 | + |
| 165 | +### Further Reading |
| 166 | + |
| 167 | +- [Getting started with Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync) |
| 168 | +- [Contentstack DataSync](https://www.contentstack.com/docs/guide/synchronization/contentstack-datasync/configuration-files-for-contentstack-datasync) doc lists the configuration for different modules |
| 169 | + |
| 170 | +### Support and Feature requests |
| 171 | + |
| 172 | +If you have any issues working with the library, please file an issue [here](https://github.com/contentstack/datasync-content-store-mongodb/issues) at Github. |
| 173 | + |
| 174 | +You can send us an e-mail at [[email protected]](mailto:[email protected]) if you have any support or feature requests. Our support team is available 24/7 on the intercom. You can always get in touch and give us an opportunity to serve you better! |
| 175 | + |
| 176 | +### License |
| 177 | + |
| 178 | +This repository is published under the [MIT license](LICENSE). |
0 commit comments