Last active
October 9, 2021 20:56
-
-
Save Pyrolistical/c82d97456bab978bc3f2ad950f5e48d9 to your computer and use it in GitHub Desktop.
separate business layer from infrastructure layer before service.js
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
export default (db) => { | |
return { | |
async checkIn(teamID) { | |
const disqualifiedPlayers = await db.collection('playerDisqualifications').find({ | |
teamID | |
}) | |
.toArray(); | |
if (disqualifiedPlayers.length > 0) { | |
throw new Error('cannot check-in with disqualified players'); | |
} | |
return db.collection('checkIns').insert({ | |
teamID, | |
checkedInAt: new Date() | |
}); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment