Answer the question
In order to leave comments, you need to log in
How to save normal information in the database?
Here I have created a data model.
import { Model, DataTypes } from 'sequelize';
import db from '../db';
interface ImgAttributes {
id: number;
fileSizeBytes: number;
url: string;
}
class Img extends Model <ImgAttributes> {}
Img.init({
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true,
},
fileSizeBytes: {
type: DataTypes.STRING(128),
allowNull: false,
},
url: {
type: DataTypes.STRING(128),
allowNull: false,
},
},
{
sequelize: db,
tableName: 'images',
});
export default Img;
await img.create({ 2, "фыаацаа"});
/home/ihor/Test Task by Komah Ihor/node_modules/ts-node/src/index.ts:587
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
src/app.ts:25:20 - error TS2345: Argument of type '{}' is not assignable to parameter of type 'ImgAttributes'.
Type '{}' is missing the following properties from type 'ImgAttributes': id, fileSizeBytes, url
25 await img.create({});
~~
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question