I found parts of a design problem with Mongoose - but maybe I'm following the wrong approach?
In the good old OOP style I have to be a class called user. Members of the class such as usernames, first names, last names, salt and hashes, and its validation is a method called head that takes the password as a logic. However, to fill my user with data, I have to type the code like this, as far as I know:
var userSchema = mongoose.Schema ({firstName: String, lastName : String, Username: string, salt: string, hash_pw: string}); UserSchema.methods = {Authentication: Function (PasswordTamch) {Return Crypto HashpoWeb (This Soulant, PasswordTamch) === this.hashed_pwd; }} This code is full of code Mungus - Calling Mongos. Sema, and user schema to add method. The method is to use. When I tried to declare my user class separately and tried to make it out of the Mongos schema from outside, I faced all kinds of errors and member law was not recognized.
So, when I want to use a different database using the same schema, I have to redistribute everything but I want to declare all the schemas separately because they are everywhere Will resume the application again.
Is there any beautiful solution to this, can I use a different library, or am I completely following the wrong approach?
Thanks in advance ..
This is probably a partial answer, but it Can help you in a helpful direction.
It's understandable what a manguah is and what it does. Mongoose is an ODM (not an ORM-TL; DR: OSM is SOL as SOL, Nonrelational DB from Relational DB) Mongoose helps certain boilers like boring stuff; Whatever you want, when it is related to any data or written in a database, this recognition comes from the mongoose.Schema with which you can define each model and every property on the model
If you want your code to be inserted Database-agnostic (i.e., anyone Minister does not need specific database), not Mongojh, if you are looking again not tied to any particular DB is important to you, you should seek a database unknowable Oarm / ODM. At the moment, it comes to mind.
It should be mentioned, if you do not care for assumptions, data casting, etc., then you can roll out vanilla mangodibi questions and whatever JSON your ( NoSQL) database compatible Javascript object but it is not recommended until you fully understand what you have lost / risk in doing so
I can also argue that there is no place in your model of authentication method and instead you should be present in a position / model of interaction (such as controller or equivalent if you are in the conference Are not following.)
No comments:
Post a Comment