Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

chore: add noti script (#1558)

bautistaaa12969697669a
diff --git a/packages/db/.eslintrc.cjs b/packages/db/.eslintrc.cjs
index 4e3f9a37..0081e9c6 100644
--- a/packages/db/.eslintrc.cjs
+++ b/packages/db/.eslintrc.cjs
@@ -5,5 +5,5 @@ module.exports = {
parserOptions: {
project: `${__dirname}/tsconfig.json`,
},
- ignorePatterns: [`mocks/test-overrides/*.ts`],
+ ignorePatterns: ['mocks/test-overrides/*.ts', 'temp/*.ts'],
};
diff --git a/packages/db/temp/create-notifications.ts b/packages/db/temp/create-notifications.ts
new file mode 100755
index 00000000..fd47d801
--- /dev/null
+++ b/packages/db/temp/create-notifications.ts
@@ -0,0 +1,39 @@
+import { prisma } from '../src';
+
+/**
+ * Usage: npx tsx ./create-notifications.ts 3660667 144733469 <--- must be two valid user ids
+ * To quickly create your notification data
+ */
+const [toUserId, fromUserId] = process.argv.slice(2);
+
+const notis = [
+ {
+ type: 'LIKE',
+ blurb: (i: number) => `liked your comment ${i}`,
+ },
+ {
+ type: 'MENTION',
+ blurb: (i: number) => `mentioned you in a comment ${i}`,
+ },
+ {
+ type: 'REPLY',
+ blurb: (i: number) => `replied to you ${i}`,
+ },
+];
+
+const notifications = Array(20)
+ .fill(null)
+ .map((_, i) => {
+ const index = Math.floor(Math.random() * 3);
+ return {
+ url: '',
+ toUserId,
+ fromUserId,
+ blurb: notis[index]?.blurb(i),
+ type: notis[index]?.type,
+ };
+ }) as any[];
+
+await prisma.notification.createMany({
+ data: notifications,
+});