Giter Site home page Giter Site logo

Comments (7)

lorefnon avatar lorefnon commented on July 21, 2024 1

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.

JordanMarr avatar JordanMarr commented on July 21, 2024

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.

lorefnon avatar lorefnon commented on July 21, 2024

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.

JordanMarr avatar JordanMarr commented on July 21, 2024

You can generate types in your Client project with set Generate HydraReader? = No.

image

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.

JordanMarr avatar JordanMarr commented on July 21, 2024

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.

lorefnon avatar lorefnon commented on July 21, 2024

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.

JordanMarr avatar JordanMarr commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.