0

Working on a small project where I need to populate a postgres database based on some log data. I've decided to use Sequelize to create my model and db connection.

When trying to call SignalDegs.create() to insert a record I receive the below error message. I've tried to reference DataTypes and import it instead of Sequalize directly resulting in the same error. Any help would be greatly appreciated!.

Error:

throw new Error(`Unrecognized datatype for attribute "${this.name}.${name}"`);
        ^
Error: Unrecognized datatype for attribute 

Model File:

const Sequelize = require('sequelize');
const db = require('../database/index.js');

const SignalDefs = db.define(
  'signaldefs',
  {
    signalType: { primaryKey: true, type: Sequelize.STRING },
    messageSource: { primaryKey: true, type: Sequelize.STRING },
    messageName: { primaryKey: true, type: Sequelize.STRING },
    signalName: { primaryKey: true, type: Sequelize.STRING },
    unit: { primaryKey: true, type: Sequelize.STRING },
    signalID: { autoIncrement: true }
  },
  { freezeTableName: true }
);

const FloatSignals = db.define(
  'floatsignals',
  {
    floatValue: { type: Sequelize.FLOAT },
    time: { primaryKey: true, type: Sequelize.DATE },
    vehicleID: { primaryKey: true, type: Sequelize.INTEGER },
    signal: { primaryKey: true, type: Sequelize.INTEGER }
  },
  { freezeTableName: true }
);

module.exports = { SignalDefs, FloatSignals };

1 Answer 1

2
  1. You don't set a type for the signalID field
  2. Are you sure you want almost all fields of the signaldefs model to participate in primary key?
Sign up to request clarification or add additional context in comments.

1 Comment

I am a bufoon thank you, I personally wouldn't ask all the fields to participate but its a requirement. Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.