mirror of
https://github.com/pawelmalak/snippet-box.git
synced 2025-12-24 06:28:07 +01:00
Database migration to support authentication
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TagModel, SnippetModel, Snippet_TagModel } from '../models';
|
||||
import { TagModel, SnippetModel, Snippet_TagModel, UserModel } from '../models';
|
||||
|
||||
export const associateModels = async () => {
|
||||
TagModel.belongsToMany(SnippetModel, {
|
||||
@@ -12,4 +12,14 @@ export const associateModels = async () => {
|
||||
foreignKey: 'snippet_id',
|
||||
as: 'tags'
|
||||
});
|
||||
|
||||
UserModel.hasMany(SnippetModel, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'snippets'
|
||||
});
|
||||
|
||||
SnippetModel.belongsTo(UserModel, {
|
||||
foreignKey: 'createdBy',
|
||||
as: 'user'
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user