ringsig
Dependency on `window`?
Unfortunately this doesn't seem to work as I expected. Some frameworks (like Angular) now complain about importing inexistent symbols (even if they aren't used server-side).
The
delegateEvents
function being generated by the Babel transform plugin seems to be the only cause of the problem (no other dependencies on window
). It's also generated rather than imported so even a dynamic import doesn't help (note that I am compiling JSX down to JS because I don't want to expose Solid.js to end-users of the library).10 replies
Dependency on `window`?
Unfortunately that seems to generate an actual SSR bundle. What I want to do is to have Solid make the normal browser bundle, but I don't want it to error out on the server.
I've investigated the issue a bit further and found that it's because I'm bundling Solid.js into my library. The function
delegateEvents
in Solid.js depends on window
when declared (because of a default parameter). Therefore, the moment my library is imported, if window
isn't present, it errors out.
I'm still not quite sure how I can solve this. I don't want to have Solid.js as an external library that my consumers need to import.10 replies
❔ Entity Framework. Rental list
If you're storing
LoanedOn
and RepaidOn
, you can calculate LoanDuration
using RepaidOn
and LoanedOn
. Traditionally you would use a method to calculate LoanDuration
like GetLoanDuration()
but C# allows you to use 'getters' which are actually methods but you use them like properties (technically they are properties)
if you have a variable loan
, you can access loan.LoanDuration
to get the duration.
This way you don't have to store LoanDuration
separately in a column which would lead to data redundancy (not a good thing—it can lose sync and cause weird bugs)20 replies
✅ EntityFrameworkCore lists
Yes, regardless of your database type. This is known as a many-to-one relationship. However, your list items can't be a primitive; they must be a separate entity that lives in the database.
For example, you can create a Tag entity which contains the tag's name. In the Tag entity, you may optionally include a reference to the associated Guild and/or its ID.
Here's an example model:
Guild:
- string Id
- List<Tag> Tags
Tag:
- string Id
- string Name
- Guild Guild (optional)
- string GuildId (optional)
However, this won't work as string is a primitive type:
Guild:
- string Id
- List<string> Tags
That said, it is possible to store direct string lists, but it's not as straightforward. You will have to write a value converter to convert string lists to a type that is supported by EF core and back (like a delimited or JSON string which is not a good idea at all and violates the atomicity principle in ACID).
https://learn.microsoft.com/en-us/ef/core/modeling/value-conversions
4 replies