loopbackjs - Loopback default values for missing properties when fetching data from MongoDB -


how should define loopback model properties listed in model json file appear on result when properties have no value (or missing) mongodb record? should behaviour configured in loopback or in mongodb?

thanks!

mongodb schema-less database. designed in way give flexibility adding new fields document without need restart database. don't think idea handle scenario on database side.

i think best way handle setting default value every property in loopback model definition. solution has problem when data inserted database outside project. can handle missing parameter @ front-end side.

another solution can think of, implementing afterremote method checking existence of fields. in case, can use function after api route want to. can check following link more information:

https://loopback.io/doc/en/lb3/remote-hooks.html#signature


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -