-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Filter which properties are shown #259
Comments
Actually, when I wrote this I thought I could just have a CurrentUserModel and I made one, but then I realized that I can't do this because it's going to try and look for a |
We haven't implemented this, but subclassing models in an ORM is something you can do (although it's complicated: http://blog.thirst.co/post/14885390861/rails-single-table-inheritance). It sounds like what you're really wanting is a way to specify what fields get returned in a serialization. This is essentially the "scenario-based serialization" we've talked about a lot. We already handle specific scenarios for validation, and it makes sense to do the same thing for serialization. |
Right now I'm looking for a way to hide the property {
"createdAt": "2015-05-26T21:12:58.373Z",
"userName": "mdesales",
"content": "The document can be just like this...",
"id": "0907B712-FB7F-4D4A-8708-452C01B29F9C",
"type": "Document"
} Is there a way to do that? |
@marcellodesales I actually had to write some kinda crazy code which we call our It'd be nice if model did this sort of thing itself and created client ready responses, but I do realize that's probably out of the scope of the project. If you'd like @marcellodesales I can send you the custom component that's pretty specific to our app but maybe you can alter it to fit your needs. Hit me up at oscar@getpiggybank.com and I'll send you the code. |
Hi @OscarGodson That would be awesome! StrongLoop's LoopBack does exactly that... We can set which properties should be hidden or not... I will email you! It definitely would help... But hey, why don't we work to get a feature request to this project? I think this is a valid feature it should support... thanks a lot for the message! |
I recently contributed to a rails project a bit, and so I was exposed to their pattern of "Serializers". A serializer becomes a function that takes a payload of models and returns a JSON result, exists in This is a pretty clever pattern, and it might be a nice addition to Geddy as a whole. |
@FlySwatter This is exactly what we're talking about with scenario-based serialization. Is this a part of Rails, or AR? |
Right now I have a CurrentUserModel and a UserModel. the CurrentUserModel is just a UserModel minus properties I don't want to show in responses like group memberships such as user settings like
email_notifications
. It would be neat if you could do something like:The text was updated successfully, but these errors were encountered: