Skip to content

Commit 67c5fba

Browse files
committed
lib updates
1 parent ab9ce44 commit 67c5fba

File tree

6 files changed

+22
-62
lines changed

6 files changed

+22
-62
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
22
## Contentstack Sync Mongodb SDK
33

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

66
[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.
77

example/index.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const Contentstack = require('../dist').Contentstack
2-
// const Stack = require('../dist/contentstack').Stack
3-
// import * as Contentstack from '../dist'
42

53
const Stack = Contentstack.Stack({
64
api_key: '',
@@ -15,11 +13,15 @@ const Stack = Contentstack.Stack({
1513
relative_url_prefix: '/es/'
1614
}
1715
],
16+
contentStore: {
17+
dbName: 'mydb',
18+
collectionName: 'dev'
19+
}
1820
})
1921

2022
function connect () {
2123
return new Promise((resolve, reject) => {
22-
return Stack.connect({dbName: 'sync-test', collectionName: 'core'})
24+
return Stack.connect()
2325
.then(resolve)
2426
.catch(reject)
2527
})
@@ -29,25 +31,18 @@ function close () {
2931
return Stack.close()
3032
}
3133

32-
function find (contentType = 'blog') {
34+
function find (contentType = 'authors') {
3335
return new Promise((resolve, reject) => {
3436
Stack.contentType(contentType)
3537
.entries()
36-
// .includeCount()
38+
.includeCount()
3739
.includeReferences()
38-
// .queryReferences({'authors.category': {}})
39-
// .includeSchema()
40-
// .language('es-es')
41-
// .notEqualTo('title', 'Blog One')
42-
// .query({tags: {$in: ['one', 'two']}})
43-
.queryReferences({'authors.category.uid': 'c2'})
44-
// .excludeReferences()
45-
// .excludeAssets()
46-
// .limit(1)
47-
// .skip(1)
48-
// .query({
49-
// uid: 'blt17559b99fee73d6f'
50-
// })
40+
.includeSchema()
41+
.language('es-es')
42+
.notEqualTo('title', 'Kolan')
43+
.query({tags: {$in: ['one', 'two']}})
44+
.limit(10)
45+
.skip(1)
5146
.find()
5247
.then(resolve)
5348
.catch(reject)
@@ -68,20 +63,18 @@ return connect()
6863
// age: null,
6964
// summary: '',
7065
// tags: [
71-
7266
// ],
7367
// locale: 'es-es',
7468
// uid: 'blt17559b99fee73d6f'
7569
// }
7670
// ],
7771
// content_type_uid: 'authors',
78-
// locale: 'es-es'
72+
// locale: 'es-es',
73+
// count: 10
7974
// }
8075
console.log(JSON.stringify(result, null, 1))
76+
return
8177
})
8278
})
8379
.then(close)
84-
.then(() => {
85-
console.info('Data received successfully!')
86-
})
8780
.catch(console.error)

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"clean": "rimraf dist typings coverage",
88
"build-ts": "npm run clean && tsc",
99
"watch-ts": "npm run clean && tsc -w",
10+
"compile": "tsc",
11+
"prepare": "npm run compile",
1012
"start": "dist/index.js",
1113
"tslint": "npx tslint -c tslint.json 'src/**/*.ts' --fix",
1214
"test": "jest"

0 commit comments

Comments
 (0)