wasowasowaso
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { BelongsToGetAssociationMixin, UUIDV4 } from 'sequelize';
|
||||
import {
|
||||
Association, DataTypes, HasManyAddAssociationMixin, HasManyCountAssociationsMixin,
|
||||
HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin,
|
||||
HasManySetAssociationsMixin, HasManyAddAssociationsMixin, HasManyHasAssociationsMixin,
|
||||
HasManyRemoveAssociationMixin, HasManyRemoveAssociationsMixin, Model, ModelDefined, Optional,
|
||||
Sequelize, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ForeignKey,
|
||||
} from 'sequelize';
|
||||
import { UserModel } from '@/model/sequelize/User';
|
||||
|
||||
const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: 'db.sqlite'
|
||||
});
|
||||
class ResourceModel extends Model<InferAttributes<ResourceModel, { omit: 'owner' }>, InferCreationAttributes<ResourceModel, { omit: 'owner' }>>{
|
||||
declare id: CreationOptional<string>;
|
||||
declare path: string;
|
||||
declare owner: NonAttribute<UserModel>;
|
||||
declare getOwner: BelongsToGetAssociationMixin<UserModel>;
|
||||
|
||||
// user_id: number | undefined;
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
// declare title
|
||||
declare static associations: {
|
||||
owner: Association<ResourceModel,UserModel>;
|
||||
};
|
||||
}
|
||||
|
||||
ResourceModel.init({
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: false,
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: UUIDV4,
|
||||
primaryKey: true,
|
||||
unique: true,
|
||||
},
|
||||
path: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
type: DataTypes.DATE
|
||||
}
|
||||
},{
|
||||
sequelize,
|
||||
tableName: 'Resource'
|
||||
});
|
||||
// export const MResource = sequelize.define<ResourceModel>(
|
||||
// 'Resource',
|
||||
// {
|
||||
// id: {
|
||||
// allowNull: false,
|
||||
// autoIncrement: false,
|
||||
// type: DataTypes.UUID,
|
||||
// defaultValue: UUIDV4,
|
||||
// primaryKey: true,
|
||||
// unique: true,
|
||||
// },
|
||||
// path: {
|
||||
// type: DataTypes.STRING,
|
||||
// },
|
||||
// user_id: {
|
||||
// type: DataTypes.INTEGER,
|
||||
// key: "User"
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// UserModel.hasMany(MResource);
|
||||
// ResourceModel.belongsTo(UserModel);
|
||||
Reference in New Issue
Block a user