-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import BaseSeeder from '@ioc:Adonis/Lucid/Seeder' | ||
import User from "App/Models/User"; | ||
import Env from "@ioc:Adonis/Core/Env"; | ||
import AuthService from "App/Services/AuthService"; | ||
import User from 'App/Models/User' | ||
import Env from '@ioc:Adonis/Core/Env' | ||
import AuthService from 'App/Services/AuthService' | ||
|
||
export default class extends BaseSeeder { | ||
public async run () { | ||
public async run() { | ||
const username = Env.get('SITE_NAME') | ||
const token = await AuthService.computedToken(username) | ||
await User.createMany([ | ||
{ | ||
username, | ||
token | ||
} | ||
]) | ||
const token: string = await AuthService.computedToken(username) | ||
|
||
const userAlreadyExists: User | null = await User.findBy('username', username) | ||
|
||
if (!userAlreadyExists) { | ||
await User.createMany([ | ||
{ | ||
username, | ||
token, | ||
}, | ||
]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import BaseSeeder from '@ioc:Adonis/Lucid/Seeder' | ||
import Channel from "App/Models/Channel"; | ||
import Channel from 'App/Models/Channel' | ||
|
||
export default class extends BaseSeeder { | ||
public async run () { | ||
await Channel.createMany([ | ||
{ | ||
name: 'general' | ||
} | ||
]) | ||
public async run() { | ||
const channelAlreadyExists: Channel | null = await Channel.findBy('name', 'general') | ||
|
||
if (!channelAlreadyExists) { | ||
await Channel.createMany([ | ||
{ | ||
name: 'general', | ||
}, | ||
]) | ||
} | ||
} | ||
} |