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
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
5
6
-
(Contentstack sync utility)[] 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.
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.
7
7
8
8
### Prerequisite
9
9
@@ -14,30 +14,33 @@ Contentstack is a headless CMS with an API-first approach. It is a CMS that deve
14
14
15
15
To import the SDK in your project, use the following command:
To initialize the SDK, you'd need to perform the following steps
21
21
22
22
1. Initialize stack instance.
23
23
```js
24
-
const Stack = contentstack.Stack(config)
24
+
constStack=Contentstack.Stack(config)
25
25
```
26
-
2. Call the connect method. The connect method connects the SDK to the database. Callthis, before running SDK queries
26
+
27
+
2. Call the connect method. This method establishes a connection between the SDK and mongodb database.
27
28
```js
28
29
Stack.connect(dbConfig)
29
-
.then()
30
-
.catch()
30
+
.then(fnResolve)
31
+
.catch(fnReject)
31
32
```
33
+
> Important: You need to call this, before running SDK queries!
34
+
32
35
Once you have initialized the SDK, you can start querying on the sync-utility's DB's
33
36
34
37
### Querying
35
38
36
-
Notes
37
-
- By default, 'content_type_uid' and 'locale' keys as part of the response.
38
-
- If `.language()` is not provided, then the 1st language, provided in config would be considered.
39
-
- If querying for a single entry/asset (using `.entry()`OR`.findOne()`), the result will be an object i.e. `{ entry: {} }`, if the entry or asset is not found, `{ entry: null }` will be returned.
- By default, 'content_type_uid' and 'locale' keys as part of the response.
41
+
- If `.language()` is not provided, then the 1st language, provided in `config.locales` would be considered.
42
+
- If querying for a single entry/asset (using `.entry()` OR `.findOne()`), the result will be an object i.e. `{ entry: {} }`, if the entry or asset is not found, `{ entry: null }` will be returned.
0 commit comments