Comments (7)
Ah, this is perfect - I missed out that I could already just prevent the readers from getting generated. Thanks a lot.
I'm not sure if you will be able to select your Client entities directly via SqlHydra.Query using the Server generated readers...
I don't think this is gonna be a problem, because the types are basically same I can conditionally open different modules eg.
#if FABLE_COMPILER
open Proj.Shared.DTO.``public``
#else
open Proj.Server.DAO.``public``
#endif
from sqlhydra.
Thanks for the feedback.
If I understand correctly, you want to put your generated types into the Shared
project (assuming you are using a SAFE style template that creates Client
, Shared
and Server
projects), and the readers into the Server
project so that you can use the generated types as DTOs.
Personally, I only use the generated records for strongly typed data access, so I always map the data into custom domain objects or DTOs for use in my app. I would generally not want to have my database schema made directly available to the client for various reasons (tight coupling, inflexibility, etc).
However, I am assuming your use case is for quick and easy CRUD style data? If so, I can definitely understand the appeal and convenience factor of such a design.
from sqlhydra.
Yes, exactly. The app I am prototyping is (atleast yet) very simple and many of the entity types used in the API map 1:1 to the table row types, so I thought if I could just have the types generated in a separate module I could use the same on the client.
While I have only used SqlHydra for an hr or so, love the DX so far - thanks for creating and open sourcing this library.
from sqlhydra.
You can generate types in your Client
project with set Generate HydraReader?
= No
.
Your server generated types will still create both types and readers.
I'm not sure if you will be able to select
your Client
entities directly via SqlHydra.Query
using the Server
generated readers...
If you can't do that, then you should be able to use AutoMapper to fairly easily translate from your Server
entities to your Client
entities in one-line of code and without any mapping required since the types would be identical.
from sqlhydra.
One last thing:
After you run this it will automatically try to add SharedTypes.fs
to your Server.fsproj
file:
<Compile Include="SharedTypes.fs">
<Visible>False</Visible>
</Compile>
If you delete it, it will just add it back every time, but if you change it to None
, it will see that it exists and will not try to update it anymore.
<None Include="SharedTypes.fs">
<Visible>False</Visible>
</None>
from sqlhydra.
Umm, if these two are in different modules, then why do I need to care about this ?
Is this primarily to prevent accidental usage or reduce build times ?
from sqlhydra.
Yes of course, you shouldn't have to worry about that as long as you generate your toml files in separate projects.
from sqlhydra.
Related Issues (20)
- Add support in SqlHydra CLI for mySQL HOT 3
- Creating sqlhydra file updates the wrong .fsproj file HOT 9
- SQL Server Temporal Tables Select Issue HOT 8
- Retrieve Multiple result sets (UNION ALL) using SqlHydra.Query HOT 1
- Insert and Update Builders break when column name is the same as another table. HOT 2
- Mapping object with list of objects 1 to n relationship HOT 4
- Best practice for multiple environments and the config.toml file HOT 7
- Design patterns for DDD HOT 8
- Is it possible to support materialized views from Postgres? HOT 22
- Generate types in GitHub workflow generates no table types HOT 5
- Show filter info in SqlHydra.Cli command line output HOT 1
- Custom pooling with SqlHydra HOT 8
- SqlHydra.Cli doesn't map Sqlite longvarchar column types HOT 5
- Error after upgrading V2.5.0: 'Microsoft.FSharp.Core.FSharpOption`1 is not a F# record type. HOT 9
- Public Schema Not Properly Escaped for NpgSQL in v2.4+ HOT 2
- Query with `leftJoin` breaks in v2.5.0 HOT 3
- Is it possible call `date_trunc` from PostgreSQL? HOT 7
- NoWarn 3391 HOT 3
- System.InvalidOperationException: The input sequence has an insufficient number of elements. HOT 3
- Support arrays HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlhydra.