Skip to content
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

Database View #77

Closed
sidazhang opened this issue Sep 19, 2014 · 9 comments
Closed

Database View #77

sidazhang opened this issue Sep 19, 2014 · 9 comments
Labels

Comments

@sidazhang
Copy link

Hi,

I am only able to see tables in express-admin however, I am not able to see database views. Is there a way to enable views?

@simov
Copy link
Owner

simov commented Sep 19, 2014

Hi @sidazhang

I guess your question is about the custom views like this one If that's the case you can pull the examples repository and see how the custom views are configured there. Also take a look at the documentation

@simov simov added the question label Sep 19, 2014
@sidazhang
Copy link
Author

@simov, the question is actually simpler than a custom view!

It was asking about database view like this: http://www.postgresql.org/docs/8.3/static/tutorial-views.html

When reading, database views are basically the same as tables. And in custom.json, I also see that express-admin has pulled all the relevant database view datas. However, it is only rendering the tables.

Is there a way to render the views as well?

@knownasilya
Copy link

👍 This would be very helpful!

@simov simov added feature and removed question labels Sep 19, 2014
@simov
Copy link
Owner

simov commented Sep 19, 2014

Ok, I got it. Marked this issue as a feature.

@sidazhang currently showing sql views is not supported. I'll make a few tests first to get an idea of how the code base should be updated.

@sidazhang
Copy link
Author

@simov Thanks!

I am surprised that it doesn't support views (but then I am not familiar the code base :P ), since views is basically exactly the same as tables queries wise.

custom.json also already grabs the column information of the views as well!

@simov
Copy link
Owner

simov commented Sep 23, 2014

@sidazhang I think adding of readonly views will be relatively easy to implement. Non readonly views will require a bit more thinking, because the admin's listview and editview are designed for tables with primary key. As I'm understanding the views have specific requirements in order to update them, also obviously they don't have their own primary key. So do you have such views in your use case?

@sidazhang
Copy link
Author

@simov My use case involves strictly readonly views.

Supporting readonly views would be an awesome feature 👍

Thank you very much :)

@simov
Copy link
Owner

simov commented Sep 24, 2014

@sidazhang just pushed the fix. I still don't have tests for it, but in the meantime you can pull master and test it out with your views.

Here are the steps you can make, essentially that will be the test for readonly views:

  1. Start the admin

  2. In settings.json you have all views added as regular tables + they have one additional key "view":true

    "my_view": {
      "table":{
        ...
        "view": true
      }
    }
  3. All views are shown under the Views section in Mainview

  4. In Listview you have a filter and pagination for your views
    Here is what you can do to test it:

    • configure a filter for your view's listview and test out filtering
    • test out ordering
    • test out whether the pagination works correctly

Keep in mind that some of the settings options for regular tables won't work for views.

@simov
Copy link
Owner

simov commented Oct 4, 2014

@simov simov closed this as completed Oct 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants