-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get Virtual Attributes to show up in any api response #117
Comments
I don't think that there are tests on virtual attributes, but there is also
no specific logic about it in this lib, so it can also be an ObjectionJS
issue.
Can you try with older feathers-objection versions?
בתאריך יום ו׳, 18 בספט׳ 2020, 17:51, מאת kaizenseed <
notifications@github.com>:
… Hello & thanks for the awesome package 👍
I'm seeing an issue that on the surface looks to be similar to #45
<#45>
except I am not sure which version of objection, feathers-objection
resulted in the virtual attributes no longer being part of the api
responses.
My (simplified) model class :
class Subscriber extends Model {
static get tableName() {
return 'subscribers';
}
static get jsonSchema() {
return {
type: 'object',
required: ['email'],
properties: {
id: { type: 'integer' },
email: { type: 'string', format: 'email' }, // validating this here via pattern did not work
name: { type: 'string' },
twitterHandle: { type: 'string', pattern: ***@***.***_]{1,16})?$" },
// pattern : must begin with @ and be followed by alphanumeric string or _ and only 15 chanracters allowed
about: { type: 'string' },
approvedAt: { type: 'string', format: 'date-time' },
}
};
}
static get virtualAttributes() {
return ['approved'];
}
approved() {
return this.approvedAt !== null
}
}
the service is the standard service generated by feathers cli. I've tried
overriding the model level parsing functions but they don't get hit in a
simple get call at all
api response to a get call is as follows (notes is a column in the db but
not defined in JsonSchema)
{ "id": 1, "email": ***@***.***", "name": "Blah", "twitterHandle":
"", "about": "", "notes": null }
Any pointers to what I may be doing wrong would help
From my package.json file
"objection": "^2.2.3", "feathers-objection": "^5.8.1",
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#117>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB5E3OYED2RWMB5HHLYOETSGNXWZANCNFSM4RSDGK6Q>
.
|
Makes sense. I'll try tracing out where it broke by downgrading the |
Huh. Weird.
the secretFields for this service includes additional meta fields like |
@kaizenseed Did you comment out code in the feathers NPM module? |
ah no sorry for the confusion.. I'll show all my code again
The subscriber service
The subscriber hooks & subscriber class is fairly standard
So no modification of anything at the package level, just added application level hooks to handle removing respective |
Hi I was finally able to look at this some more and 99% sure this doesn't have anything to do with |
Thank you @kaizenseed 👍 |
additional info for documentation + want to get it confirmed that my thought process is correct
This is based on that I got it to work by replacing the
the Thus I'm assuming even though the object is no longer recognized by objection as the |
Hello & thanks for the awesome package 👍
I'm seeing an issue that on the surface looks to be similar to #45 except I am not sure which version of objection, feathers-objection resulted in the virtual attributes no longer being part of the api responses.
My (simplified) model class :
the service is the standard service generated by feathers cli. I've tried overriding the model level parsing functions but they don't get hit in a simple get call at all
api response to a get call is as follows (notes is a column in the db but not defined in JsonSchema)
{ "id": 1, "email": "blah@gmail.com", "name": "Blah", "twitterHandle": "", "about": "", "notes": null }
Any pointers to what I may be doing wrong would help
From my
package.json
file"objection": "^2.2.3", "feathers-objection": "^5.8.1",
The text was updated successfully, but these errors were encountered: