Skip to content

Commit dc2aba0

Browse files
committed
backup
2 parents f9324db + db9cece commit dc2aba0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+26041
-384
lines changed

.babelrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslint.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

.npmignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ coverage
77
jest.config.js
88

99
# Configs
10+
.jsbeautifyrc
1011
tsconfig.json
11-
.babelrc
1212

1313
# Source files
1414
src
1515

16-
# Examples
17-
example/**/*
18-
!example/index.js
16+
# Gitignore
17+
.gitignore

README.md

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,69 @@
11
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2-
## Contentstack Sync Mongodb SDK
32

4-
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/).
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-
[Contentstack sync utility](https://www.contentstack.com/docs/tools-and-frameworks) provides Mongodb SDK to query applications that have locally strored contents in mongodb. Given below is the detailed guide and helpful resources to get started with Mongodb SDK.
5+
## Contentstack DataSync MongoDB SDK
6+
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.
78

89
### Prerequisite
910

10-
- nodejs, v6 or higher
11-
- mongodb, v3.6 or higher
11+
- nodejs, v8+
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+
|limit|number|100|**Optional.** Caps the total no of objects returned in a single call|
23+
|skip|number|0|**Optional.** Number of objects skipped before the result is returned|
24+
| indexes | object |**[see config below](https://github.com/contentstack/datasync-content-store-mongodb#detailed-configs)** |**Optional.** Option to create db indexes via configuration|
25+
|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|
26+
|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|
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+
```
1267

1368
### Setup and Installation
1469

@@ -102,4 +157,22 @@ Once you have initialized the SDK, you can start querying on the sync-utility's
102157
})
103158
.catch(reject)
104159
```
105-
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
66
*/
@@ -10,6 +10,7 @@ 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
@@ -20,6 +21,7 @@ exports.config = {
2021
},
2122
limit: 100,
2223
locales: [],
24+
// http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html
2325
options: {
2426
autoReconnect: true,
2527
connectTimeoutMS: 15000,

dist/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
"use strict";
22
/*!
3-
* Contentstack Sync Mongodb SDK
3+
* Contentstack DataSync Mongodb SDK
44
* Copyright (c) 2019 Contentstack LLC
55
* MIT Licensed
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} Returns Stack method, which's used to create an instance of Stack
27+
*/
928
class Contentstack {
29+
/**
30+
* @public
31+
* @method Stack
32+
* @summary Initialize Stack instance
33+
* @param {object} config Stack config
34+
* @param {object} db Existing db connection
35+
* @returns {Stack} - Returns an instance of `Stack`
36+
*/
1037
static Stack(config, db) {
1138
return new stack_1.Stack(config, db);
1239
}

0 commit comments

Comments
 (0)