38820-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-27 19:23:09 +00:00

8044 lines
172 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Posts = db.posts;
const Comments = db.comments;
const Reactions = db.reactions;
const Follows = db.follows;
const Hashtags = db.hashtags;
const PostHashtags = db.post_hashtags;
const Mentions = db.mentions;
const Stories = db.stories;
const StoryViews = db.story_views;
const StoryReactions = db.story_reactions;
const ChatThreads = db.chat_threads;
const ThreadMembers = db.thread_members;
const Messages = db.messages;
const Notifications = db.notifications;
const Reports = db.reports;
const Blocks = db.blocks;
const SavedItems = db.saved_items;
const UserSettings = db.user_settings;
const AdminAuditLogs = db.admin_audit_logs;
const PostsData = [
{
// type code here for "relation_one" field
"post_type": "photo",
"caption": "Grace Hopper",
"visibility": "public",
// type code here for "images" field
// type code here for "files" field
"duration_seconds": 6,
"music_title": "Grace Hopper",
"music_artist": "Alan Turing",
"music_source_url": "Alan Turing",
"allow_comments": false,
"allow_remix": true,
"is_sensitive": false,
"is_archived": false,
"is_pinned": false,
"location_name": "Alan Turing",
"location_lat": 8.03,
"location_lng": 5.16,
"published_at": new Date(Date.now()),
"scheduled_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"post_type": "photo",
"caption": "Alan Turing",
"visibility": "private",
// type code here for "images" field
// type code here for "files" field
"duration_seconds": 3,
"music_title": "Ada Lovelace",
"music_artist": "Ada Lovelace",
"music_source_url": "Grace Hopper",
"allow_comments": true,
"allow_remix": false,
"is_sensitive": false,
"is_archived": false,
"is_pinned": false,
"location_name": "Ada Lovelace",
"location_lat": 4.05,
"location_lng": 3.69,
"published_at": new Date(Date.now()),
"scheduled_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"post_type": "photo",
"caption": "Ada Lovelace",
"visibility": "followers",
// type code here for "images" field
// type code here for "files" field
"duration_seconds": 8,
"music_title": "Marie Curie",
"music_artist": "Marie Curie",
"music_source_url": "Ada Lovelace",
"allow_comments": false,
"allow_remix": true,
"is_sensitive": true,
"is_archived": true,
"is_pinned": true,
"location_name": "Alan Turing",
"location_lat": 0.42,
"location_lng": 2.12,
"published_at": new Date(Date.now()),
"scheduled_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"post_type": "carousel",
"caption": "Ada Lovelace",
"visibility": "private",
// type code here for "images" field
// type code here for "files" field
"duration_seconds": 3,
"music_title": "Alan Turing",
"music_artist": "Alan Turing",
"music_source_url": "Marie Curie",
"allow_comments": false,
"allow_remix": false,
"is_sensitive": false,
"is_archived": true,
"is_pinned": false,
"location_name": "Alan Turing",
"location_lat": 2.35,
"location_lng": 3.84,
"published_at": new Date(Date.now()),
"scheduled_at": new Date(Date.now()),
},
];
const CommentsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Ada Lovelace",
"is_hidden": false,
"is_pinned": true,
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Grace Hopper",
"is_hidden": false,
"is_pinned": true,
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Alan Turing",
"is_hidden": false,
"is_pinned": true,
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Ada Lovelace",
"is_hidden": true,
"is_pinned": true,
"edited_at": new Date(Date.now()),
},
];
const ReactionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "love",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "sad",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "love",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "bookmark",
"reacted_at": new Date(Date.now()),
},
];
const FollowsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "pending",
"notifications_enabled": false,
"requested_at": new Date(Date.now()),
"accepted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "blocked",
"notifications_enabled": false,
"requested_at": new Date(Date.now()),
"accepted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"notifications_enabled": true,
"requested_at": new Date(Date.now()),
"accepted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "blocked",
"notifications_enabled": true,
"requested_at": new Date(Date.now()),
"accepted_at": new Date(Date.now()),
},
];
const HashtagsData = [
{
"tag": "Alan Turing",
"description": "Grace Hopper",
"is_banned": true,
"usage_count": 4,
},
{
"tag": "Grace Hopper",
"description": "Alan Turing",
"is_banned": true,
"usage_count": 7,
},
{
"tag": "Alan Turing",
"description": "Grace Hopper",
"is_banned": false,
"usage_count": 7,
},
{
"tag": "Ada Lovelace",
"description": "Alan Turing",
"is_banned": true,
"usage_count": 3,
},
];
const PostHashtagsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const MentionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"start_index": 4,
"end_index": 1,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"start_index": 6,
"end_index": 8,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"start_index": 5,
"end_index": 3,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"start_index": 9,
"end_index": 1,
},
];
const StoriesData = [
{
// type code here for "relation_one" field
"story_type": "text",
// type code here for "images" field
// type code here for "files" field
"text_overlay": "Ada Lovelace",
"visibility": "public",
"allow_replies": false,
"published_at": new Date(Date.now()),
"expires_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"story_type": "video",
// type code here for "images" field
// type code here for "files" field
"text_overlay": "Marie Curie",
"visibility": "public",
"allow_replies": true,
"published_at": new Date(Date.now()),
"expires_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"story_type": "video",
// type code here for "images" field
// type code here for "files" field
"text_overlay": "Ada Lovelace",
"visibility": "followers",
"allow_replies": false,
"published_at": new Date(Date.now()),
"expires_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"story_type": "image",
// type code here for "images" field
// type code here for "files" field
"text_overlay": "Grace Hopper",
"visibility": "close_friends",
"allow_replies": true,
"published_at": new Date(Date.now()),
"expires_at": new Date(Date.now()),
},
];
const StoryViewsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"viewed_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"viewed_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"viewed_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"viewed_at": new Date(Date.now()),
},
];
const StoryReactionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "laugh",
"emoji": "Marie Curie",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "angry",
"emoji": "Ada Lovelace",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "sad",
"emoji": "Alan Turing",
"reacted_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reaction_type": "love",
"emoji": "Alan Turing",
"reacted_at": new Date(Date.now()),
},
];
const ChatThreadsData = [
{
"thread_type": "direct",
"title": "Marie Curie",
// type code here for "images" field
// type code here for "relation_one" field
"is_archived": false,
"last_message_at": new Date(Date.now()),
},
{
"thread_type": "direct",
"title": "Grace Hopper",
// type code here for "images" field
// type code here for "relation_one" field
"is_archived": true,
"last_message_at": new Date(Date.now()),
},
{
"thread_type": "direct",
"title": "Grace Hopper",
// type code here for "images" field
// type code here for "relation_one" field
"is_archived": false,
"last_message_at": new Date(Date.now()),
},
{
"thread_type": "direct",
"title": "Grace Hopper",
// type code here for "images" field
// type code here for "relation_one" field
"is_archived": false,
"last_message_at": new Date(Date.now()),
},
];
const ThreadMembersData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"role": "admin",
"is_muted": false,
"joined_at": new Date(Date.now()),
"last_read_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"role": "member",
"is_muted": true,
"joined_at": new Date(Date.now()),
"last_read_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"role": "owner",
"is_muted": true,
"joined_at": new Date(Date.now()),
"last_read_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"role": "member",
"is_muted": false,
"joined_at": new Date(Date.now()),
"last_read_at": new Date(Date.now()),
},
];
const MessagesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_type": "profile_share",
"body": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_deleted": true,
"sent_at": new Date(Date.now()),
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_type": "video",
"body": "Marie Curie",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_deleted": true,
"sent_at": new Date(Date.now()),
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_type": "file",
"body": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_deleted": true,
"sent_at": new Date(Date.now()),
"edited_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_type": "profile_share",
"body": "Ada Lovelace",
// type code here for "images" field
// type code here for "files" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_deleted": true,
"sent_at": new Date(Date.now()),
"edited_at": new Date(Date.now()),
},
];
const NotificationsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"notification_type": "follow_request",
"title": "Grace Hopper",
"body": "Grace Hopper",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_read": true,
"read_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"notification_type": "comment",
"title": "Marie Curie",
"body": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_read": false,
"read_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"notification_type": "story_reaction",
"title": "Ada Lovelace",
"body": "Ada Lovelace",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_read": true,
"read_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"notification_type": "follow_accepted",
"title": "Grace Hopper",
"body": "Grace Hopper",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"is_read": true,
"read_at": new Date(Date.now()),
"sent_at": new Date(Date.now()),
},
];
const ReportsData = [
{
// type code here for "relation_one" field
"target_type": "story",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"reason": "Alan Turing",
"status": "open",
// type code here for "relation_one" field
"admin_note": "Marie Curie",
"reported_at": new Date(Date.now()),
"resolved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"target_type": "story",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"reason": "Alan Turing",
"status": "in_review",
// type code here for "relation_one" field
"admin_note": "Marie Curie",
"reported_at": new Date(Date.now()),
"resolved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"target_type": "story",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"reason": "Grace Hopper",
"status": "resolved",
// type code here for "relation_one" field
"admin_note": "Ada Lovelace",
"reported_at": new Date(Date.now()),
"resolved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"target_type": "story",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"reason": "Grace Hopper",
"status": "open",
// type code here for "relation_one" field
"admin_note": "Ada Lovelace",
"reported_at": new Date(Date.now()),
"resolved_at": new Date(Date.now()),
},
];
const BlocksData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note": "Ada Lovelace",
"blocked_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note": "Alan Turing",
"blocked_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note": "Marie Curie",
"blocked_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"note": "Alan Turing",
"blocked_at": new Date(Date.now()),
},
];
const SavedItemsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"saved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"saved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"saved_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"saved_at": new Date(Date.now()),
},
];
const UserSettingsData = [
{
// type code here for "relation_one" field
"push_enabled": true,
"email_enabled": true,
"sms_enabled": false,
"mute_all": false,
"language": "en",
"theme": "light",
"reel_autoplay": "never",
},
{
// type code here for "relation_one" field
"push_enabled": false,
"email_enabled": false,
"sms_enabled": true,
"mute_all": false,
"language": "tr",
"theme": "dark",
"reel_autoplay": "wifi_only",
},
{
// type code here for "relation_one" field
"push_enabled": false,
"email_enabled": false,
"sms_enabled": true,
"mute_all": false,
"language": "tr",
"theme": "system",
"reel_autoplay": "always",
},
{
// type code here for "relation_one" field
"push_enabled": true,
"email_enabled": true,
"sms_enabled": true,
"mute_all": true,
"language": "tr",
"theme": "light",
"reel_autoplay": "always",
},
];
const AdminAuditLogsData = [
{
// type code here for "relation_one" field
"action": "resolve_report",
"entity_name": "Alan Turing",
"entity_key": "Marie Curie",
"details": "Grace Hopper",
"ip_address": "Grace Hopper",
"user_agent": "Marie Curie",
"logged_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"action": "unhide",
"entity_name": "Grace Hopper",
"entity_key": "Ada Lovelace",
"details": "Alan Turing",
"ip_address": "Grace Hopper",
"user_agent": "Ada Lovelace",
"logged_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"action": "create",
"entity_name": "Alan Turing",
"entity_key": "Grace Hopper",
"details": "Ada Lovelace",
"ip_address": "Grace Hopper",
"user_agent": "Ada Lovelace",
"logged_at": new Date(Date.now()),
},
{
// type code here for "relation_one" field
"action": "unhide",
"entity_name": "Ada Lovelace",
"entity_key": "Grace Hopper",
"details": "Ada Lovelace",
"ip_address": "Grace Hopper",
"user_agent": "Grace Hopper",
"logged_at": new Date(Date.now()),
},
];
// Similar logic for "relation_many"
async function associatePostWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post0 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Post0?.setAuthor)
{
await
Post0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post1 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Post1?.setAuthor)
{
await
Post1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post2 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Post2?.setAuthor)
{
await
Post2.
setAuthor(relatedAuthor2);
}
const relatedAuthor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post3 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Post3?.setAuthor)
{
await
Post3.
setAuthor(relatedAuthor3);
}
}
async function associateCommentWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setPost)
{
await
Comment0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setPost)
{
await
Comment1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setPost)
{
await
Comment2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment3 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Comment3?.setPost)
{
await
Comment3.
setPost(relatedPost3);
}
}
async function associateCommentWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setAuthor)
{
await
Comment0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setAuthor)
{
await
Comment1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setAuthor)
{
await
Comment2.
setAuthor(relatedAuthor2);
}
const relatedAuthor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment3 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Comment3?.setAuthor)
{
await
Comment3.
setAuthor(relatedAuthor3);
}
}
async function associateCommentWithParent_comment() {
const relatedParent_comment0 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setParent_comment)
{
await
Comment0.
setParent_comment(relatedParent_comment0);
}
const relatedParent_comment1 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setParent_comment)
{
await
Comment1.
setParent_comment(relatedParent_comment1);
}
const relatedParent_comment2 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setParent_comment)
{
await
Comment2.
setParent_comment(relatedParent_comment2);
}
const relatedParent_comment3 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Comment3 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Comment3?.setParent_comment)
{
await
Comment3.
setParent_comment(relatedParent_comment3);
}
}
async function associateReactionWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Reaction0 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Reaction0?.setPost)
{
await
Reaction0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Reaction1 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Reaction1?.setPost)
{
await
Reaction1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Reaction2 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Reaction2?.setPost)
{
await
Reaction2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Reaction3 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Reaction3?.setPost)
{
await
Reaction3.
setPost(relatedPost3);
}
}
async function associateReactionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Reaction0 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Reaction0?.setUser)
{
await
Reaction0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Reaction1 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Reaction1?.setUser)
{
await
Reaction1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Reaction2 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Reaction2?.setUser)
{
await
Reaction2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Reaction3 = await Reactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Reaction3?.setUser)
{
await
Reaction3.
setUser(relatedUser3);
}
}
async function associateFollowWithFollower() {
const relatedFollower0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow0 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Follow0?.setFollower)
{
await
Follow0.
setFollower(relatedFollower0);
}
const relatedFollower1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow1 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Follow1?.setFollower)
{
await
Follow1.
setFollower(relatedFollower1);
}
const relatedFollower2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow2 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Follow2?.setFollower)
{
await
Follow2.
setFollower(relatedFollower2);
}
const relatedFollower3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow3 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Follow3?.setFollower)
{
await
Follow3.
setFollower(relatedFollower3);
}
}
async function associateFollowWithFollowing() {
const relatedFollowing0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow0 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Follow0?.setFollowing)
{
await
Follow0.
setFollowing(relatedFollowing0);
}
const relatedFollowing1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow1 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Follow1?.setFollowing)
{
await
Follow1.
setFollowing(relatedFollowing1);
}
const relatedFollowing2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow2 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Follow2?.setFollowing)
{
await
Follow2.
setFollowing(relatedFollowing2);
}
const relatedFollowing3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow3 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Follow3?.setFollowing)
{
await
Follow3.
setFollowing(relatedFollowing3);
}
}
async function associatePostHashtagWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const PostHashtag0 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PostHashtag0?.setPost)
{
await
PostHashtag0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const PostHashtag1 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PostHashtag1?.setPost)
{
await
PostHashtag1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const PostHashtag2 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PostHashtag2?.setPost)
{
await
PostHashtag2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const PostHashtag3 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PostHashtag3?.setPost)
{
await
PostHashtag3.
setPost(relatedPost3);
}
}
async function associatePostHashtagWithHashtag() {
const relatedHashtag0 = await Hashtags.findOne({
offset: Math.floor(Math.random() * (await Hashtags.count())),
});
const PostHashtag0 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PostHashtag0?.setHashtag)
{
await
PostHashtag0.
setHashtag(relatedHashtag0);
}
const relatedHashtag1 = await Hashtags.findOne({
offset: Math.floor(Math.random() * (await Hashtags.count())),
});
const PostHashtag1 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PostHashtag1?.setHashtag)
{
await
PostHashtag1.
setHashtag(relatedHashtag1);
}
const relatedHashtag2 = await Hashtags.findOne({
offset: Math.floor(Math.random() * (await Hashtags.count())),
});
const PostHashtag2 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PostHashtag2?.setHashtag)
{
await
PostHashtag2.
setHashtag(relatedHashtag2);
}
const relatedHashtag3 = await Hashtags.findOne({
offset: Math.floor(Math.random() * (await Hashtags.count())),
});
const PostHashtag3 = await PostHashtags.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PostHashtag3?.setHashtag)
{
await
PostHashtag3.
setHashtag(relatedHashtag3);
}
}
async function associateMentionWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Mention0 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Mention0?.setPost)
{
await
Mention0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Mention1 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Mention1?.setPost)
{
await
Mention1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Mention2 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Mention2?.setPost)
{
await
Mention2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Mention3 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Mention3?.setPost)
{
await
Mention3.
setPost(relatedPost3);
}
}
async function associateMentionWithMentioned_user() {
const relatedMentioned_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention0 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Mention0?.setMentioned_user)
{
await
Mention0.
setMentioned_user(relatedMentioned_user0);
}
const relatedMentioned_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention1 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Mention1?.setMentioned_user)
{
await
Mention1.
setMentioned_user(relatedMentioned_user1);
}
const relatedMentioned_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention2 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Mention2?.setMentioned_user)
{
await
Mention2.
setMentioned_user(relatedMentioned_user2);
}
const relatedMentioned_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention3 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Mention3?.setMentioned_user)
{
await
Mention3.
setMentioned_user(relatedMentioned_user3);
}
}
async function associateMentionWithMentioned_by() {
const relatedMentioned_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention0 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Mention0?.setMentioned_by)
{
await
Mention0.
setMentioned_by(relatedMentioned_by0);
}
const relatedMentioned_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention1 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Mention1?.setMentioned_by)
{
await
Mention1.
setMentioned_by(relatedMentioned_by1);
}
const relatedMentioned_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention2 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Mention2?.setMentioned_by)
{
await
Mention2.
setMentioned_by(relatedMentioned_by2);
}
const relatedMentioned_by3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Mention3 = await Mentions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Mention3?.setMentioned_by)
{
await
Mention3.
setMentioned_by(relatedMentioned_by3);
}
}
async function associateStoryWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Story0 = await Stories.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Story0?.setAuthor)
{
await
Story0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Story1 = await Stories.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Story1?.setAuthor)
{
await
Story1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Story2 = await Stories.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Story2?.setAuthor)
{
await
Story2.
setAuthor(relatedAuthor2);
}
const relatedAuthor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Story3 = await Stories.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Story3?.setAuthor)
{
await
Story3.
setAuthor(relatedAuthor3);
}
}
async function associateStoryViewWithStory() {
const relatedStory0 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryView0 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StoryView0?.setStory)
{
await
StoryView0.
setStory(relatedStory0);
}
const relatedStory1 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryView1 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StoryView1?.setStory)
{
await
StoryView1.
setStory(relatedStory1);
}
const relatedStory2 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryView2 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StoryView2?.setStory)
{
await
StoryView2.
setStory(relatedStory2);
}
const relatedStory3 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryView3 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StoryView3?.setStory)
{
await
StoryView3.
setStory(relatedStory3);
}
}
async function associateStoryViewWithViewer() {
const relatedViewer0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryView0 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StoryView0?.setViewer)
{
await
StoryView0.
setViewer(relatedViewer0);
}
const relatedViewer1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryView1 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StoryView1?.setViewer)
{
await
StoryView1.
setViewer(relatedViewer1);
}
const relatedViewer2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryView2 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StoryView2?.setViewer)
{
await
StoryView2.
setViewer(relatedViewer2);
}
const relatedViewer3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryView3 = await StoryViews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StoryView3?.setViewer)
{
await
StoryView3.
setViewer(relatedViewer3);
}
}
async function associateStoryReactionWithStory() {
const relatedStory0 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryReaction0 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StoryReaction0?.setStory)
{
await
StoryReaction0.
setStory(relatedStory0);
}
const relatedStory1 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryReaction1 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StoryReaction1?.setStory)
{
await
StoryReaction1.
setStory(relatedStory1);
}
const relatedStory2 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryReaction2 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StoryReaction2?.setStory)
{
await
StoryReaction2.
setStory(relatedStory2);
}
const relatedStory3 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const StoryReaction3 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StoryReaction3?.setStory)
{
await
StoryReaction3.
setStory(relatedStory3);
}
}
async function associateStoryReactionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryReaction0 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (StoryReaction0?.setUser)
{
await
StoryReaction0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryReaction1 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (StoryReaction1?.setUser)
{
await
StoryReaction1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryReaction2 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (StoryReaction2?.setUser)
{
await
StoryReaction2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const StoryReaction3 = await StoryReactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (StoryReaction3?.setUser)
{
await
StoryReaction3.
setUser(relatedUser3);
}
}
async function associateChatThreadWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatThread0 = await ChatThreads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ChatThread0?.setCreated_by_user)
{
await
ChatThread0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatThread1 = await ChatThreads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ChatThread1?.setCreated_by_user)
{
await
ChatThread1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatThread2 = await ChatThreads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ChatThread2?.setCreated_by_user)
{
await
ChatThread2.
setCreated_by_user(relatedCreated_by_user2);
}
const relatedCreated_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatThread3 = await ChatThreads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ChatThread3?.setCreated_by_user)
{
await
ChatThread3.
setCreated_by_user(relatedCreated_by_user3);
}
}
async function associateThreadMemberWithThread() {
const relatedThread0 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const ThreadMember0 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ThreadMember0?.setThread)
{
await
ThreadMember0.
setThread(relatedThread0);
}
const relatedThread1 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const ThreadMember1 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ThreadMember1?.setThread)
{
await
ThreadMember1.
setThread(relatedThread1);
}
const relatedThread2 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const ThreadMember2 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ThreadMember2?.setThread)
{
await
ThreadMember2.
setThread(relatedThread2);
}
const relatedThread3 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const ThreadMember3 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ThreadMember3?.setThread)
{
await
ThreadMember3.
setThread(relatedThread3);
}
}
async function associateThreadMemberWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ThreadMember0 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ThreadMember0?.setUser)
{
await
ThreadMember0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ThreadMember1 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ThreadMember1?.setUser)
{
await
ThreadMember1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ThreadMember2 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ThreadMember2?.setUser)
{
await
ThreadMember2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ThreadMember3 = await ThreadMembers.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ThreadMember3?.setUser)
{
await
ThreadMember3.
setUser(relatedUser3);
}
}
async function associateMessageWithThread() {
const relatedThread0 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setThread)
{
await
Message0.
setThread(relatedThread0);
}
const relatedThread1 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setThread)
{
await
Message1.
setThread(relatedThread1);
}
const relatedThread2 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setThread)
{
await
Message2.
setThread(relatedThread2);
}
const relatedThread3 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Message3 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Message3?.setThread)
{
await
Message3.
setThread(relatedThread3);
}
}
async function associateMessageWithSender() {
const relatedSender0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setSender)
{
await
Message0.
setSender(relatedSender0);
}
const relatedSender1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setSender)
{
await
Message1.
setSender(relatedSender1);
}
const relatedSender2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setSender)
{
await
Message2.
setSender(relatedSender2);
}
const relatedSender3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message3 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Message3?.setSender)
{
await
Message3.
setSender(relatedSender3);
}
}
async function associateMessageWithShared_post() {
const relatedShared_post0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setShared_post)
{
await
Message0.
setShared_post(relatedShared_post0);
}
const relatedShared_post1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setShared_post)
{
await
Message1.
setShared_post(relatedShared_post1);
}
const relatedShared_post2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setShared_post)
{
await
Message2.
setShared_post(relatedShared_post2);
}
const relatedShared_post3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Message3 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Message3?.setShared_post)
{
await
Message3.
setShared_post(relatedShared_post3);
}
}
async function associateMessageWithShared_story() {
const relatedShared_story0 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setShared_story)
{
await
Message0.
setShared_story(relatedShared_story0);
}
const relatedShared_story1 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setShared_story)
{
await
Message1.
setShared_story(relatedShared_story1);
}
const relatedShared_story2 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setShared_story)
{
await
Message2.
setShared_story(relatedShared_story2);
}
const relatedShared_story3 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Message3 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Message3?.setShared_story)
{
await
Message3.
setShared_story(relatedShared_story3);
}
}
async function associateMessageWithShared_profile() {
const relatedShared_profile0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setShared_profile)
{
await
Message0.
setShared_profile(relatedShared_profile0);
}
const relatedShared_profile1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setShared_profile)
{
await
Message1.
setShared_profile(relatedShared_profile1);
}
const relatedShared_profile2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setShared_profile)
{
await
Message2.
setShared_profile(relatedShared_profile2);
}
const relatedShared_profile3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message3 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Message3?.setShared_profile)
{
await
Message3.
setShared_profile(relatedShared_profile3);
}
}
async function associateNotificationWithRecipient() {
const relatedRecipient0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setRecipient)
{
await
Notification0.
setRecipient(relatedRecipient0);
}
const relatedRecipient1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setRecipient)
{
await
Notification1.
setRecipient(relatedRecipient1);
}
const relatedRecipient2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setRecipient)
{
await
Notification2.
setRecipient(relatedRecipient2);
}
const relatedRecipient3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setRecipient)
{
await
Notification3.
setRecipient(relatedRecipient3);
}
}
async function associateNotificationWithActor() {
const relatedActor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setActor)
{
await
Notification0.
setActor(relatedActor0);
}
const relatedActor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setActor)
{
await
Notification1.
setActor(relatedActor1);
}
const relatedActor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setActor)
{
await
Notification2.
setActor(relatedActor2);
}
const relatedActor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setActor)
{
await
Notification3.
setActor(relatedActor3);
}
}
async function associateNotificationWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setPost)
{
await
Notification0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setPost)
{
await
Notification1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setPost)
{
await
Notification2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setPost)
{
await
Notification3.
setPost(relatedPost3);
}
}
async function associateNotificationWithComment() {
const relatedComment0 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setComment)
{
await
Notification0.
setComment(relatedComment0);
}
const relatedComment1 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setComment)
{
await
Notification1.
setComment(relatedComment1);
}
const relatedComment2 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setComment)
{
await
Notification2.
setComment(relatedComment2);
}
const relatedComment3 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setComment)
{
await
Notification3.
setComment(relatedComment3);
}
}
async function associateNotificationWithStory() {
const relatedStory0 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setStory)
{
await
Notification0.
setStory(relatedStory0);
}
const relatedStory1 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setStory)
{
await
Notification1.
setStory(relatedStory1);
}
const relatedStory2 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setStory)
{
await
Notification2.
setStory(relatedStory2);
}
const relatedStory3 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setStory)
{
await
Notification3.
setStory(relatedStory3);
}
}
async function associateNotificationWithThread() {
const relatedThread0 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setThread)
{
await
Notification0.
setThread(relatedThread0);
}
const relatedThread1 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setThread)
{
await
Notification1.
setThread(relatedThread1);
}
const relatedThread2 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setThread)
{
await
Notification2.
setThread(relatedThread2);
}
const relatedThread3 = await ChatThreads.findOne({
offset: Math.floor(Math.random() * (await ChatThreads.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setThread)
{
await
Notification3.
setThread(relatedThread3);
}
}
async function associateReportWithReported_by() {
const relatedReported_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setReported_by)
{
await
Report0.
setReported_by(relatedReported_by0);
}
const relatedReported_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setReported_by)
{
await
Report1.
setReported_by(relatedReported_by1);
}
const relatedReported_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setReported_by)
{
await
Report2.
setReported_by(relatedReported_by2);
}
const relatedReported_by3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setReported_by)
{
await
Report3.
setReported_by(relatedReported_by3);
}
}
async function associateReportWithTarget_user() {
const relatedTarget_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setTarget_user)
{
await
Report0.
setTarget_user(relatedTarget_user0);
}
const relatedTarget_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setTarget_user)
{
await
Report1.
setTarget_user(relatedTarget_user1);
}
const relatedTarget_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setTarget_user)
{
await
Report2.
setTarget_user(relatedTarget_user2);
}
const relatedTarget_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setTarget_user)
{
await
Report3.
setTarget_user(relatedTarget_user3);
}
}
async function associateReportWithTarget_post() {
const relatedTarget_post0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setTarget_post)
{
await
Report0.
setTarget_post(relatedTarget_post0);
}
const relatedTarget_post1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setTarget_post)
{
await
Report1.
setTarget_post(relatedTarget_post1);
}
const relatedTarget_post2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setTarget_post)
{
await
Report2.
setTarget_post(relatedTarget_post2);
}
const relatedTarget_post3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setTarget_post)
{
await
Report3.
setTarget_post(relatedTarget_post3);
}
}
async function associateReportWithTarget_comment() {
const relatedTarget_comment0 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setTarget_comment)
{
await
Report0.
setTarget_comment(relatedTarget_comment0);
}
const relatedTarget_comment1 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setTarget_comment)
{
await
Report1.
setTarget_comment(relatedTarget_comment1);
}
const relatedTarget_comment2 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setTarget_comment)
{
await
Report2.
setTarget_comment(relatedTarget_comment2);
}
const relatedTarget_comment3 = await Comments.findOne({
offset: Math.floor(Math.random() * (await Comments.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setTarget_comment)
{
await
Report3.
setTarget_comment(relatedTarget_comment3);
}
}
async function associateReportWithTarget_story() {
const relatedTarget_story0 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setTarget_story)
{
await
Report0.
setTarget_story(relatedTarget_story0);
}
const relatedTarget_story1 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setTarget_story)
{
await
Report1.
setTarget_story(relatedTarget_story1);
}
const relatedTarget_story2 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setTarget_story)
{
await
Report2.
setTarget_story(relatedTarget_story2);
}
const relatedTarget_story3 = await Stories.findOne({
offset: Math.floor(Math.random() * (await Stories.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setTarget_story)
{
await
Report3.
setTarget_story(relatedTarget_story3);
}
}
async function associateReportWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setAssigned_to)
{
await
Report0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setAssigned_to)
{
await
Report1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setAssigned_to)
{
await
Report2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report3 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Report3?.setAssigned_to)
{
await
Report3.
setAssigned_to(relatedAssigned_to3);
}
}
async function associateBlockWithBlocker() {
const relatedBlocker0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block0 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Block0?.setBlocker)
{
await
Block0.
setBlocker(relatedBlocker0);
}
const relatedBlocker1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block1 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Block1?.setBlocker)
{
await
Block1.
setBlocker(relatedBlocker1);
}
const relatedBlocker2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block2 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Block2?.setBlocker)
{
await
Block2.
setBlocker(relatedBlocker2);
}
const relatedBlocker3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block3 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Block3?.setBlocker)
{
await
Block3.
setBlocker(relatedBlocker3);
}
}
async function associateBlockWithBlocked_user() {
const relatedBlocked_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block0 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Block0?.setBlocked_user)
{
await
Block0.
setBlocked_user(relatedBlocked_user0);
}
const relatedBlocked_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block1 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Block1?.setBlocked_user)
{
await
Block1.
setBlocked_user(relatedBlocked_user1);
}
const relatedBlocked_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block2 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Block2?.setBlocked_user)
{
await
Block2.
setBlocked_user(relatedBlocked_user2);
}
const relatedBlocked_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Block3 = await Blocks.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Block3?.setBlocked_user)
{
await
Block3.
setBlocked_user(relatedBlocked_user3);
}
}
async function associateSavedItemWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SavedItem0 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SavedItem0?.setUser)
{
await
SavedItem0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SavedItem1 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SavedItem1?.setUser)
{
await
SavedItem1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SavedItem2 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SavedItem2?.setUser)
{
await
SavedItem2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SavedItem3 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SavedItem3?.setUser)
{
await
SavedItem3.
setUser(relatedUser3);
}
}
async function associateSavedItemWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const SavedItem0 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SavedItem0?.setPost)
{
await
SavedItem0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const SavedItem1 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SavedItem1?.setPost)
{
await
SavedItem1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const SavedItem2 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SavedItem2?.setPost)
{
await
SavedItem2.
setPost(relatedPost2);
}
const relatedPost3 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const SavedItem3 = await SavedItems.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SavedItem3?.setPost)
{
await
SavedItem3.
setPost(relatedPost3);
}
}
async function associateUserSettingWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSetting0 = await UserSettings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (UserSetting0?.setUser)
{
await
UserSetting0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSetting1 = await UserSettings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (UserSetting1?.setUser)
{
await
UserSetting1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSetting2 = await UserSettings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (UserSetting2?.setUser)
{
await
UserSetting2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const UserSetting3 = await UserSettings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (UserSetting3?.setUser)
{
await
UserSetting3.
setUser(relatedUser3);
}
}
async function associateAdminAuditLogWithActor() {
const relatedActor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdminAuditLog0 = await AdminAuditLogs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdminAuditLog0?.setActor)
{
await
AdminAuditLog0.
setActor(relatedActor0);
}
const relatedActor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdminAuditLog1 = await AdminAuditLogs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdminAuditLog1?.setActor)
{
await
AdminAuditLog1.
setActor(relatedActor1);
}
const relatedActor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdminAuditLog2 = await AdminAuditLogs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdminAuditLog2?.setActor)
{
await
AdminAuditLog2.
setActor(relatedActor2);
}
const relatedActor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdminAuditLog3 = await AdminAuditLogs.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdminAuditLog3?.setActor)
{
await
AdminAuditLog3.
setActor(relatedActor3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Posts.bulkCreate(PostsData);
await Comments.bulkCreate(CommentsData);
await Reactions.bulkCreate(ReactionsData);
await Follows.bulkCreate(FollowsData);
await Hashtags.bulkCreate(HashtagsData);
await PostHashtags.bulkCreate(PostHashtagsData);
await Mentions.bulkCreate(MentionsData);
await Stories.bulkCreate(StoriesData);
await StoryViews.bulkCreate(StoryViewsData);
await StoryReactions.bulkCreate(StoryReactionsData);
await ChatThreads.bulkCreate(ChatThreadsData);
await ThreadMembers.bulkCreate(ThreadMembersData);
await Messages.bulkCreate(MessagesData);
await Notifications.bulkCreate(NotificationsData);
await Reports.bulkCreate(ReportsData);
await Blocks.bulkCreate(BlocksData);
await SavedItems.bulkCreate(SavedItemsData);
await UserSettings.bulkCreate(UserSettingsData);
await AdminAuditLogs.bulkCreate(AdminAuditLogsData);
await Promise.all([
// Similar logic for "relation_many"
await associatePostWithAuthor(),
await associateCommentWithPost(),
await associateCommentWithAuthor(),
await associateCommentWithParent_comment(),
await associateReactionWithPost(),
await associateReactionWithUser(),
await associateFollowWithFollower(),
await associateFollowWithFollowing(),
await associatePostHashtagWithPost(),
await associatePostHashtagWithHashtag(),
await associateMentionWithPost(),
await associateMentionWithMentioned_user(),
await associateMentionWithMentioned_by(),
await associateStoryWithAuthor(),
await associateStoryViewWithStory(),
await associateStoryViewWithViewer(),
await associateStoryReactionWithStory(),
await associateStoryReactionWithUser(),
await associateChatThreadWithCreated_by_user(),
await associateThreadMemberWithThread(),
await associateThreadMemberWithUser(),
await associateMessageWithThread(),
await associateMessageWithSender(),
await associateMessageWithShared_post(),
await associateMessageWithShared_story(),
await associateMessageWithShared_profile(),
await associateNotificationWithRecipient(),
await associateNotificationWithActor(),
await associateNotificationWithPost(),
await associateNotificationWithComment(),
await associateNotificationWithStory(),
await associateNotificationWithThread(),
await associateReportWithReported_by(),
await associateReportWithTarget_user(),
await associateReportWithTarget_post(),
await associateReportWithTarget_comment(),
await associateReportWithTarget_story(),
await associateReportWithAssigned_to(),
await associateBlockWithBlocker(),
await associateBlockWithBlocked_user(),
await associateSavedItemWithUser(),
await associateSavedItemWithPost(),
await associateUserSettingWithUser(),
await associateAdminAuditLogWithActor(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('posts', null, {});
await queryInterface.bulkDelete('comments', null, {});
await queryInterface.bulkDelete('reactions', null, {});
await queryInterface.bulkDelete('follows', null, {});
await queryInterface.bulkDelete('hashtags', null, {});
await queryInterface.bulkDelete('post_hashtags', null, {});
await queryInterface.bulkDelete('mentions', null, {});
await queryInterface.bulkDelete('stories', null, {});
await queryInterface.bulkDelete('story_views', null, {});
await queryInterface.bulkDelete('story_reactions', null, {});
await queryInterface.bulkDelete('chat_threads', null, {});
await queryInterface.bulkDelete('thread_members', null, {});
await queryInterface.bulkDelete('messages', null, {});
await queryInterface.bulkDelete('notifications', null, {});
await queryInterface.bulkDelete('reports', null, {});
await queryInterface.bulkDelete('blocks', null, {});
await queryInterface.bulkDelete('saved_items', null, {});
await queryInterface.bulkDelete('user_settings', null, {});
await queryInterface.bulkDelete('admin_audit_logs', null, {});
},
};