forked from hozzjss/pollen-onboarding
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
30578e5
commit a7e0961
Showing
3 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { connect } from 'mongoose' | ||
import { config } from 'dotenv' | ||
|
||
config() | ||
|
||
export default async function connectDB() { | ||
try { | ||
await connect( | ||
process.env.MONGODB_URI, | ||
{ | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
useFindAndModify: false, | ||
useCreateIndex: true | ||
} | ||
) | ||
|
||
console.log('MongoDB Connected') | ||
} catch (err) { | ||
console.error(err.message) | ||
process.exit(1) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { model, Schema, Model, Document } from "mongoose"; | ||
|
||
interface ILedgerUpdate extends Document { | ||
modifiedAt: number | ||
} | ||
|
||
const LedgerUpdateSchema: Schema = new Schema({ | ||
modifiedAt: { type: Number } | ||
}, { | ||
versionKey: false | ||
}); | ||
|
||
const LedgerUpdate: Model<ILedgerUpdate> = model("LedgerUpdate", LedgerUpdateSchema); | ||
export default LedgerUpdate; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { model, Schema, Model, Document } from "mongoose"; | ||
|
||
export interface IUser extends Document { | ||
discordId: string, | ||
address: string, | ||
username: string, | ||
github: string, | ||
discourse: string, | ||
modifiedAt: number, | ||
createdAt: number | ||
} | ||
|
||
const UserSchema: Schema = new Schema({ | ||
discordId: { type: String, unique: true, required: true, dropDups: true }, | ||
username: { type: String, unique: true, required: true, dropDups: true }, | ||
discourse: { type: String }, | ||
github: { type: String }, | ||
address: { type: String, unique: true }, | ||
modifiedAt: { type: Number }, | ||
createdAt: { type: Number, default: Date.now() } | ||
}, { | ||
versionKey: false, | ||
_id: false | ||
}); | ||
|
||
const User: Model<IUser> = model("User", UserSchema); | ||
export default User; |