TTUSDC / cpceed-webapp

CPCEED Web App
https://ttusdc.github.io/cpceed-webapp/
3 stars 0 forks source link

Move Mongoose Schemas to Common #23

Open asclines opened 7 years ago

asclines commented 7 years ago

As of v3.9.3, Mongoose schema declarations are isomorphic, that is, you can use mongoose's browser component to validate objects against your mongoose schemas in the browser. source

It should be relatively easy to move Report and Event models to Common as both sides use the same data, but users may be a little different given that after login, the front end shouldn't retain a password.

In any event, having the models in Common allows for easy validation and consistency of data objects without duplicate code.

@NilsG-S your thoughts, as always, are much appreciated.

NilsG-S commented 7 years ago

@asclines Would this mainly be used to validate input?

asclines commented 7 years ago

Yes, primarily validation

NilsG-S commented 7 years ago

I like it. This would let me keep the client-side validation in sync with the server-side more easily

asclines commented 7 years ago

I'm considering keeping the schema just in server code. Do you think it would be better to have the whole app use it?

NilsG-S commented 7 years ago

If you're going to be using them in the server code, then I don't think it'd be necessary.

ynigoreyes commented 6 years ago

Is this issue updated? If it is, how do we plan on splitting it up into micros if the models are the same?

NilsG-S commented 6 years ago

Currently, I plan on dividing things into micros along schema lines. Each micro should only touch its own schema. If the micros need to access some functionality on another schema, we'll have to provide functionality through that schema's micro-based API.

We could still consider moving schemas to common if they help with data validation. However, I haven't done any research on whether Mongoose can be used on the front-end.