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
3. Open http://localhost:9080 in your web browser.
24
24
25
25
## Client-Side App
26
26
27
-
The client-side part is the `surveyjs-react-client` React application. The current project includes only the application's build artifacts in the /public folder. Refer to the [surveyjs-react-client](https://github.com/surveyjs/surveyjs-react-client) repo for full code and information about the application.
27
+
The client-side part is the `surveyjs-react-client` React application. The current project includes only the application's build artifacts in the [public](./public/) directory. Refer to the [`surveyjs-react-client`](https://github.com/surveyjs/surveyjs-react-client) repo for full code and information about the application.
28
+
29
+
## Integrate SurveyJS with MongoDB
30
+
31
+
SurveyJS communicates with any database using JSON objects that contain either survey schemas or user responses. A MongoDB database should have two collections to store these objects: `surveys` and `results`. You can refer to the following file to view a code example of how to create them: [`surveyjs-init.js`](mongo/entrypoint/surveyjs-init.js). The diagram below shows the structure of these collections:
32
+
33
+

34
+
35
+
To modify data in the `surveys` and `results` collections, you need to implement several JavaScript functions. According to the tasks they perform, these functions can be split into three modules:
36
+
37
+
- **Query builder**
38
+
JS functions that construct CRUD queries (see the [`nosql-crud-adapter.js`](express-app/db-adapters/nosql-crud-adapter.js) file).
39
+
40
+
- **Query runner**
41
+
JS functions that establish connection with a database to run the queries (see the [`mongo.js`](express-app/db-adapters/mongo.js) file).
42
+
43
+
- **Survey storage**
44
+
JS functions that provide an API for working with survey schemas and user responses (see the [`survey-storage.js`](express-app/db-adapters/survey-storage.js) file). This API is used by the NodeJS application router (see the [`index.js`](express-app/index.js) file).
45
+
46
+
These modules interact with each other as shown on the following diagram:
If you want to integrate SurveyJS with other databases, you can modify or replace the query builder and query runner without changing the survey storage module. This approach is applied to PostgreSQL integration in the following repository: [`surveyjs-nodejs-postgresql`](https://github.com/surveyjs/surveyjs-nodejs-postgresql).
0 commit comments