@@ -14,7 +14,7 @@ module.exports = async function makeUser({ dbConnection }) {
1414
1515 async function findAllUsers ( ) {
1616 const db = await dbConnection ( )
17- const result = await db . collection ( 'comments ' ) . find ( { } )
17+ const result = await db . collection ( 'users ' ) . find ( { } )
1818 return ( await result . toArray ( ) ) . map ( ( { _id : id , ...found } ) => ( {
1919 id,
2020 ...found
@@ -23,7 +23,7 @@ module.exports = async function makeUser({ dbConnection }) {
2323
2424 async function findUserById ( ) {
2525 const db = await dbConnection ( )
26- const result = await db . collection ( 'comments ' ) . find ( { _id } )
26+ const result = await db . collection ( 'users ' ) . find ( { _id } )
2727 const found = await result . toArray ( )
2828 if ( found . length === 0 ) {
2929 return null
@@ -35,7 +35,7 @@ module.exports = async function makeUser({ dbConnection }) {
3535 async function createUser ( { id : _id = Id . makeId ( ) , ...userData } ) {
3636 const db = await dbConnection ( )
3737 const result = await db
38- . collection ( 'comments ' )
38+ . collection ( 'users ' )
3939 . insertOne ( { _id, ...userData } )
4040 const { _id : id , ...insertedInfo } = result . ops [ 0 ]
4141 return { id, ...insertedInfo }
@@ -44,14 +44,14 @@ module.exports = async function makeUser({ dbConnection }) {
4444 async function updateUser ( { id : _id , userData } ) {
4545 const db = await dbConnection ( )
4646 const result = await db
47- . collection ( 'comments ' )
47+ . collection ( 'users ' )
4848 . updateOne ( { _id } , { $set : { ...userData } } )
4949 return result . modifiedCount > 0 ? { id : _id , ...userData } : null
5050 }
5151
5252 async function deleteUser ( { id : _id } ) {
5353 const db = await dbConnection ( )
54- const result = await db . collection ( 'comments ' ) . deleteOne ( { _id } )
54+ const result = await db . collection ( 'users ' ) . deleteOne ( { _id } )
5555 return result . deletedCount
5656 }
5757}
0 commit comments