Skip to content

Can include model schema definitions in generated $resources #194

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

Closed
wants to merge 3 commits into from

Conversation

akera-io
Copy link

Hi,

we're working on a Kendo data source that can use Strongloop REST services as 'transport' and while things are working just fine for read operations for updates the Kendo data source require some schema information - the model primary key is mandatory else no update operation can take place.

While one can add that information manually when defining the data source it's a pita not to use the information already available in our models. We've just added an option to include the model definition (properties) when generating the angular resources, this is not included by default so if you think we can merge that back in 'master' we would rather not keep the fork alive. There is a minor change in the client to accommodate this.

Best regards,
Marian Edu

[email protected]
www.acorn-it.com
www.akera.io

@slnode
Copy link

slnode commented Nov 25, 2015

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@VR-Architect
Copy link

Can someone please provide an example of how to call the LoopBack model from inside a Kendo UI datasource attribute?

@akera-io
Copy link
Author

We have some samples online although using a somehow limited version of the custom Kendo UI data source - http://repository.akera.io:8383/slc/ (Kendo Grid using Akera Angular SDK).

Since then we have extended the datasource and though we can make it generic for all LoopBack models if we can get the model definition exported on the client-side as well... what we do now for akera.io is to have a base model that exposes the 'describe' method and have all models extent that instead.

We're going to release the data source on github, guess we just have to check if the model definition can be retrieved somehow and only include the schema if that is available. Thing is for anything else beside read operations the Kendo datasource need to know the model primary key - for update, delete :(

* @description
* The schema of the model represented by this $resource
*/
R.schema = <%- JSON.stringify(meta.modelSchema, null, '\t') -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 2 spaces for indentation for consistency, we don't use tabs anywhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add ; at the end of the generated statement.

R.schema = <%- ... -%>;

@bajtos
Copy link
Member

bajtos commented Jan 25, 2016

Hi @akera-io, thank you for the pull request. Please add a unit-test to verify the implementation and address my minor comments above.

@bajtos
Copy link
Member

bajtos commented Jan 25, 2016

@slnode ok to test

@akera-io
Copy link
Author

Hi Miroslav,

addressing the comments should be straight forward, for unit-test should we add a new test in services.spec.js or what is your favourite?

Cheers,
Marian Edu

Acorn IT
www.acorn-it.comhttp://www.acorn-it.com
www.akera.iohttp://www.akera.io
+40 740 036 212

On 25 Jan 2016, at 15:27, Miroslav Bajtoš <[email protected]mailto:[email protected]> wrote:

Hi @akera-iohttps://github.com/akera-io, thank you for the pull request. Please add a unit-test to verify the implementation and address my minor comments above.


Reply to this email directly or view it on GitHubhttps://github.com//pull/194#issuecomment-174509386.

@akera-io
Copy link
Author

added unit test, hope this is how we should have added one :)

@bajtos
Copy link
Member

bajtos commented May 30, 2016

@akera-io sorry for the delay, this pull request sort of fell through cracks. As I was reviewing the code, I figured out it will be faster for me to write the correct version myself, see #223.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants