Created
July 27, 2021 16:46
-
-
Save nuelsoft/b7757995ae4ed3638c15ab601666ca87 to your computer and use it in GitHub Desktop.
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
const mongoose = require("mongoose"); | |
class UserFrame { | |
constructor(data) { | |
this.id = data._id; | |
this.email = data.email; | |
} | |
get json() { | |
return { | |
id: this.id, | |
email: this.email | |
} | |
} | |
static get schema() { | |
return new mongoose.Schema({ | |
email: String, | |
}) | |
} | |
} | |
class UserRepository { | |
static model = mongoose.model("user", UserFrame.schema) | |
static async create(user) { | |
const instance = new UserRepository.model(user); | |
return await instance.save(); | |
} | |
} | |
module.exports = {UserRepository, UserFrame} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment