SQLite / NodeJS

Hello,
my application generates normal, but cannot write to the sqlite-database. Even can’t read it. Any hints?
Kind regards
Andreas

Provide a screenshot of the error displayed.

In english it means: “Not able to process the request.”

What you shared is a generic error and can mean many things. Check your node.js terminal for the precise error.

I get:
redplan@1.0.0 start
nodemon app.js --delay 2 -e js

nodemon] 2.0.13
nodemon] to restart at any time, enter rs
nodemon] watching path(s): .
nodemon] watching extensions: js
nodemon] starting node app.js
:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\redplan\nodejs-express
api\node_modules\sequelize\lib\model.js:1001
throw new Error(Unrecognized datatype for attribute "${this.name}.${nam }");
^

rror: Unrecognized datatype for attribute “redplan.idee”
at C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\redplan\nodejs-
xpress-api\node_modules\sequelize\lib\model.js:1001:15
at C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\redplan\nodejs-
xpress-api\node_modules\sequelize\node_modules\lodash\lodash.js:13469:38
at C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\redplan\nodejs-
xpress-api\node_modules\sequelize\node_modules\lodash\lodash.js:4967:15
at baseForOwn (C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\red
lan\nodejs-express-api\node_modules\sequelize\node_modules\lodash\lodash.js:303
:24)
at Function.mapValues (C:\Users\Paperspace\Documents\RadSystems\NodeRad Proj
cts\redplan\nodejs-express-api\node_modules\sequelize\node_modules\lodash\lodas
.js:13468:7)
at redplan.init (C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\r
dplan\nodejs-express-api\node_modules\sequelize\lib\model.js:997:28)
at redplan.init (C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\r
dplan\nodejs-express-api\models\redplan.js:5:16)
at Object. (C:\Users\Paperspace\Documents\RadSystems\NodeRad Proj
cts\redplan\nodejs-express-api\models\index.js:24:39)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1272:10)

ode.js v18.13.0
nodemon] app crashed - waiting for file changes before starting…

The error stated is this: Unrecognized datatype for attribute “redplan.idee”. You have a code that is causing a problem with this file: C:\Users\Paperspace\Documents\RadSystems\NodeRad Projects\r
dplan\nodejs-express-api\models\redplan.js line 5 column 16, so check and fix it.

OR

You can share the generated file or code for that file indicating the line number.

I see no mistake;

const BaseModel = require(“./basemodel”);
class Redplan extends BaseModel {
static init(sequelize, Sequelize) {
return super.init(
{

			persona: {name: 'persona', type:Sequelize.INTEGER},
			pubdatum: {name: 'pubdatum', type:Sequelize.DATE},
			thema: {name: 'Thema', type:Sequelize.STRING},
			idee: {name: 'Idee', type:Sequelize.BYTE},
			cjphase: {name: 'cjphase', type:Sequelize.INTEGER},
			format: {name: 'format', type:Sequelize.INTEGER},
			verantwortlicher: {name: 'verantwortlicher', type:Sequelize.INTEGER},
			freigabeverantwortlicher: {name: 'freigabeverantwortlicher', type:Sequelize.INTEGER},
			deadlineerstellung: {name: 'deadlineerstellung', type:Sequelize.DATEONLY},
			deadlinefreigabe: {name: 'deadlinefreigabe', type:Sequelize.DATEONLY},
			vorschaulink: {name: 'vorschaulink', type:Sequelize.STRING},
			status: {name: 'status', type:Sequelize.INTEGER},
			notiz: {name: 'Notiz', type:Sequelize.STRING},
			id: { type: Sequelize.INTEGER, primaryKey: true , autoIncrement: true }
		}, 
		{ 
			sequelize,
			
			tableName: "redplan",
			modelName: "redplan",
		}
	);
}

static listFields() {
	const sequelize = this.sequelize;
	return [
		'id', 
		'persona', 
		'pubdatum', 
		sequelize.literal('Thema AS thema'), 
		sequelize.literal('Idee AS idee'), 
		'cjphase', 
		'format', 
		'verantwortlicher', 
		'freigabeverantwortlicher', 
		'deadlineerstellung', 
		'deadlinefreigabe', 
		'vorschaulink', 
		'status', 
		sequelize.literal('Notiz AS notiz')
	];
}

static viewFields() {
	const sequelize = this.sequelize;
	return [
		'id', 
		'persona', 
		'pubdatum', 
		sequelize.literal('Thema AS thema'), 
		sequelize.literal('Idee AS idee'), 
		'cjphase', 
		'format', 
		'verantwortlicher', 
		'freigabeverantwortlicher', 
		'deadlineerstellung', 
		'deadlinefreigabe', 
		'vorschaulink', 
		'status', 
		sequelize.literal('Notiz AS notiz')
	];
}

static editFields() {
	const sequelize = this.sequelize;
	return [
		'persona', 
		'pubdatum', 
		sequelize.literal('Thema AS thema'), 
		sequelize.literal('Idee AS idee'), 
		'cjphase', 
		'format', 
		'verantwortlicher', 
		'freigabeverantwortlicher', 
		'deadlineerstellung', 
		'deadlinefreigabe', 
		'vorschaulink', 
		'status', 
		sequelize.literal('Notiz AS notiz'), 
		'id'
	];
}


static searchFields(){
	const sequelize = this.sequelize;
	return [
		sequelize.literal("Thema LIKE :search"), 
		sequelize.literal("vorschaulink LIKE :search"), 
		sequelize.literal("Notiz LIKE :search"),
	];
}

}
module.exports = Redplan;

There is an error there. This data type BYTE does not exist in the sequelize docs. Did you modify the file or add that code?

No, everything comes from the generation and the definition from the tables in radsystems. No manual modification. I just defined the tables and clicked on publish.

Solution: I had defined a Blob-Object in a table-definition. That might not work in sqllight. When changing it to text, it work. Thank you for your help!

1 Like