Closed dalu93 closed 6 years ago
@dalu93 any particular reason why you're manually pulling out the Identifier and then passing it to the controller as oppose to just using Parameterizable
and then getting the Todo
object?
The reason is that I need the userId
which is encoded in the access_token
parameter. Then access the database by looking for the specific todo for the specific user. @0xTim
@dalu93 Just use String
if you want to support all identifier types. That's what we would do with a .identifier
property anyway. (The equality operator should work fine between ex: 42
, "42"
, and 42.0
). Also it's possible to add the .identifier
property as an extension in your code if you want it.
We're working on moving away from the StructuredDataWrapper
type in the next version of Node so hopefully that will make things more clear.
Closing as Fluent 3 has no more Identifier
!
Hi,
I'm spending some time trying out Vapor2 a bit and I have to say that, imo, the code is now much better than the version 1.0. Thank you all guys :)
Going to the question, I'm a bit confused with the
Identifier
concept. By implementing aModel
usingFluent
, the idea is to hide any database-related logic from our code, to make it more maintainable and easy to change to other engines. But theIdentifier
class is still a bit unclear to me.I'm now using a
postgres
database, so a normal table id value is anInt
. In mongo it will probably be an object or aString
. So far everything is ok.My
Todo
object as anIdentifier
and the router should handle aGET /todos/:id
. Here is the problem: how I'm supposed to handle theid
type?What I ended up is this
In my case, an
Int
is convertible to aString
type, so I hope that, whenFluent
will be comparingIdentifier
s, the equality will be verified correctly. Am I correct? Is there a more elegant way to handle this without passing by aString
object? I would have expected something similar towhich will abstract the
Identifier
type at all. What do you think? Also because the subscript value is already aStructuredDataWrapper
object.