-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from TogetherCrew/114-new-db-models-schema-an…
…d-methods 114 new db models schema and methods
- Loading branch information
Showing
19 changed files
with
240 additions
and
292 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Community } from '../../../src/models'; | ||
import { ICommunity } from '../../../src/interfaces'; | ||
import { Types } from 'mongoose'; | ||
|
||
describe('Community model', () => { | ||
describe('Community validation', () => { | ||
let community: ICommunity; | ||
beforeEach(() => { | ||
community = { | ||
name: 'community1', | ||
users: [new Types.ObjectId()], | ||
}; | ||
}); | ||
|
||
test('should correctly validate a valid community', async () => { | ||
await expect(new Community(community).validate()).resolves.toBeUndefined(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import { Platfrom } from '../../../src/models'; | ||
import { IPlatform } from '../../../src/interfaces'; | ||
import { Types } from 'mongoose'; | ||
|
||
describe('Platfrom model', () => { | ||
describe('Platform validation', () => { | ||
let platfrom: IPlatform; | ||
beforeEach(() => { | ||
platfrom = { | ||
name: 'Discord', | ||
community: new Types.ObjectId(), | ||
}; | ||
}); | ||
|
||
test('should correctly validate a valid platfrom', async () => { | ||
await expect(new Platfrom(platfrom).validate()).resolves.toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { type Model, type Types } from 'mongoose'; | ||
|
||
export interface ICommunity { | ||
name: string; | ||
avatarURL?: string; | ||
users: [Types.ObjectId]; | ||
platforms?: [Types.ObjectId]; | ||
} | ||
|
||
export interface ICommunityUpdateBody { | ||
name?: string; | ||
avatarURL?: string; | ||
users?: [Types.ObjectId]; | ||
platforms?: [Types.ObjectId]; | ||
} | ||
|
||
export interface CommunityModel extends Model<ICommunity> { | ||
paginate: (filter: object, options: object) => any; | ||
} |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import { type Model, type Types } from 'mongoose'; | ||
|
||
export interface IPlatform { | ||
name: string; | ||
community: Types.ObjectId; | ||
metadata?: Record<string, any>; // dynamic object since structure can change | ||
disconnectedAt?: Date | null; | ||
} | ||
|
||
export interface IPlatformUpdateBody { | ||
name?: string; | ||
community?: Types.ObjectId; | ||
metadata?: Record<string, any>; | ||
disconnectedAt?: Date | null; | ||
} | ||
|
||
export interface PlatformModel extends Model<IPlatform> { | ||
paginate: (filter: object, options: object) => any; | ||
} |
Oops, something went wrong.