Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Apr 23, 2024
2 parents c772559 + 5a63455 commit 5db5419
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions __tests__/unit/models/module.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Module model', () => {
metadata: {
selectedChannels: ['c1', 'c2'],
},
name: 'discord',
},
],
},
Expand Down
34 changes: 17 additions & 17 deletions __tests__/utils/setupTestDB.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import mongoose from 'mongoose';
import config from '../../src/config';
// import mongoose from 'mongoose';
// import config from '../../src/config';

const setupTestDB = () => {
beforeAll(async () => {
mongoose.set('strictQuery', false);
await mongoose.connect(config.mongoose.serverURL);
});
// const setupTestDB = () => {
// beforeAll(async () => {
// mongoose.set('strictQuery', false);
// await mongoose.connect(config.mongoose.serverURL);
// });

beforeEach(async () => {
await Promise.all(
Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany({})),
);
});
// beforeEach(async () => {
// await Promise.all(
// Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany({})),
// );
// });

afterAll(async () => {
await mongoose.disconnect();
});
};
// afterAll(async () => {
// await mongoose.disconnect();
// });
// };

export default setupTestDB;
// export default setupTestDB;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@togethercrew.dev/db",
"version": "3.0.51",
"version": "3.0.52",
"description": "All interactions with DB",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/Module.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface IModule {
options?: {
platforms: Array<{
platform: Types.ObjectId;
name: 'discord';
metadata?: Record<string, any>; // dynamic object since structure can change
}>;
};
Expand All @@ -14,6 +15,7 @@ export interface IModuleUpdateBody {
options?: {
platforms: Array<{
platform: Types.ObjectId;
name: 'discord';
metadata?: Record<string, any>; // dynamic object since structure can change
}>;
};
Expand Down
5 changes: 5 additions & 0 deletions src/models/schemas/Module.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const moduleSchema = new Schema<IModule, ModuleModel>(
metadata: {
type: Schema.Types.Mixed,
},
name: {
type: String,
required: true,
enum: ['discord'],
},
},
],
},
Expand Down

0 comments on commit 5db5419

Please sign in to comment.