Closed shin-deok closed 2 years ago
You can change it in this function https://github.com/surveyjs/surveyjs-nodejs/blob/master/index.js#L19-L23
Thank you, In fact, I already changed that function as blow.
1) var db = new dbadapter(); //var db = new inmemorydbadapter(req.session);
2) //var db = new inmemorydbadapter(req.session); var db = new PostgresDBAdapter();
But New survey I made was not saved in database. What is wrong I did?
Thank you.
You need to create a database and write your connection string in the https://github.com/surveyjs/surveyjs-nodejs/blob/master/dbadapter.js file. Probably you will need to debug this file and change it according your needs.
I changed a database. So demo surveys are disappeared successfully. Thank you.
But I meet the new error as below when I clicked the 'Add' button on my creator page.
console.log(dbadapter: PostgresDBAdapter);
WARNING: Creating a duplicate database object for the same connection.
at new PostgresDBAdapter (D:\100. VSCode_Projects\4_Survey_Creator\surveyjs-nodejs\dbadapter.js:6:12)
at getDBAdapter (D:\100. VSCode_Projects\4_Survey_Creator\surveyjs-nodejs\index.js:23:12)
at Layer.handle [as handle_request] (D:\100. VSCode_Projects\4_Survey_Creator\surveyjs-nodejs\node_modules\express\lib\router\layer.js:95:5)
at next (D:\100. VSCode_Projects\4_Survey_Creator\surveyjs-nodejs\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (D:\100. VSCode_Projects\4_Survey_Creator\surveyjs-nodejs\node_modules\express\lib\router\route.js:112:3)
Please let me know how I can fix it. Thank you.
Probably you need to use connection pool or close/recreate connection as discussed here - https://stackoverflow.com/questions/62193189/how-to-fix-the-duplicate-database-object-for-the-same-connection-dynamodb-warn
looks like a database schema is needed.
The error I get on connection to the DB is:
(node:16226) UnhandledPromiseRejectionWarning: error: relation "surveys" does not exist
The schema is very simple: surveys table contains id, name, json fields results table contains id, surveyId, resultJson
Thanks, I note that for users creating the DB in an existing postgres DB (not docker) then the init.sql
file can be used to create the schema.
This demo shows how to integrate SurveyJS products with the node.js backend. We're using here in-memory data base with very simple structure and suppose that one who wants to use PostgreSQL, or MySQL, or other DBMS is familiar with it. One can debug server endpoint calls and can see - what data are being passed and received during API calls.
I've removed PostgreSQL DB adapter
I'm a beginner about the surveyjs and the nodejs.
I want to know how I can change the db adapter from InMemoryDBAdapter to Postgresql one in Survey-Creator.
Thank you