Skip to content

Commit dbc32cf

Browse files
committed
backup
1 parent f1d012f commit dbc32cf

15 files changed

+802
-27
lines changed

README.md

+76-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,69 @@
11
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2-
## Contentstack Sync Mongodb SDK
32

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/).
54

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
76

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.
148

159
### Prerequisite
1610

1711
- nodejs, v8+
18-
- Data synced via mongodb content store
1912
- 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+
```
2067

2168
### Setup and Installation
2269

@@ -110,4 +157,22 @@ Once you have initialized the SDK, you can start querying on the sync-utility's
110157
})
111158
.catch(reject)
112159
```
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).

dist/config.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ exports.config = {
1010
collectionName: 'contents',
1111
dbName: 'contentstack-persistent-db',
1212
indexes: {
13+
published_at: -1,
1314
content_type_uid: 1,
1415
locale: 1,
1516
uid: 1
1617
},
1718
limit: 100,
1819
locales: [],
20+
// http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html
1921
options: {
2022
autoReconnect: true,
2123
connectTimeoutMS: 15000,

dist/index.js

+24
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,31 @@
66
*/
77
Object.defineProperty(exports, "__esModule", { value: true });
88
const stack_1 = require("./stack");
9+
/**
10+
* @class Stack
11+
* @description Initialize an instance of `Stack`
12+
* @api public
13+
* @example
14+
* const Stack = Contentstack.Stack({
15+
* contentStore: {
16+
* baseDir: '../../dev-contents'
17+
* },
18+
* locales: [
19+
* {
20+
* code: 'en-us',
21+
* relative_url_prefix: '/'
22+
* }
23+
* ]
24+
* })
25+
*
26+
* @returns {Stack}
27+
*/
928
class Contentstack {
29+
/**
30+
* @summary
31+
* Initialize Stack instance
32+
* @param {Object} stack_arguments - Stack config
33+
*/
1034
static Stack(config, db) {
1135
return new stack_1.Stack(config, db);
1236
}

0 commit comments

Comments
 (0)