Isn't it dangerous to have query information in javascript using breezejs?

后端 未结 3 521
清酒与你
清酒与你 2021-02-12 11:23

Just starting to play with breeze.js because of the obvious gains in coding time, i.e. managing to access model data from the server direct within Javascript (I am a newbie here

3条回答
  •  逝去的感伤
    2021-02-12 12:04

    It can be dangerous to expose the full business model. It can be dangerous to allow unrestrained querying of even that part of the model that you want to expose to the client. This is true whether you offer an easy-to-query API or one that is difficult to query.

    That's why our teams are careful about how we construct our services.

    You should only expose types that your client app needs. If you want to limit access to authorized instances of a type, you can write carefully prescribed non-queryable service methods. Breeze can call them just fine. You don't have to use the Breeze query facilities for every request. You'll still benefit from the caching, related-entity-navigation, change-tracking, validation, save-bundling, cache-querying, offline support.

    Repeat: your service methods don't have to return IQueryable. Even when they do return IQueryable, you can easily write the service method to constrain the query results to just those entities the user is authorized to see.

    Fortunately, you can blend the two approaches in the same service or in collaborating services.

    Breeze gives you choices. It's up to you to exercise those choices wisely. Go out there and design your services to fit your requirements.

提交回复
热议问题