Skip to content

Can include model schema definitions in generated $resources - #194

Closed
akera-io wants to merge 3 commits into
strongloop:masterfrom
akera-io:master
Closed

akera-io wants to merge 3 commits into
strongloop:masterfrom
akera-io:master

Conversation

@akera-io

Copy link
Copy Markdown

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

marian.edu@acorn.ro
www.acorn-it.com
www.akera.io

@slnode

slnode commented Nov 25, 2015

Copy link
Copy Markdown

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
Copy Markdown

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

@akera-io

Copy link
Copy Markdown
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 :(

Comment thread lib/services.template.ejs Outdated

Copy link
Copy Markdown
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
Copy Markdown
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

bajtos commented Jan 25, 2016

Copy link
Copy Markdown
Member

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

bajtos commented Jan 25, 2016

Copy link
Copy Markdown
Member

@slnode ok to test

@akera-io

Copy link
Copy Markdown
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š <notifications@github.commailto:notifications@github.com> 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
Copy Markdown
Author

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

@bajtos

bajtos commented May 30, 2016

Copy link
Copy Markdown
Member

@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