Support > Repository > Model > Use database view

"View" prepared in the database can be treated as "Wagby" model.

It is possible to make reference to the view prepared in the database without creating the physical table of the model defined by Wagby.

Figure 1 Refer to view

The definition method is as follows.

  1. It is set not to create a table.
  2. Specify the view name in the physical table name.(It can be omitted if model name and view name are the same.)

Main key handling

Even when using views, you need a primary key.(Wagby's model must specify primary key.)

If there is no primary key in the view of the existing database, please add it.

Cache handling

When using views with updating, it is necessary to consider the handling of caches. For details, please read "Notes on Table Operations Summary> Cash".

You can use group privileges provided by Wagby by preparing the following on the view side (of the database to use).

  • Useridjshparam column.
  • (View name) $ jgroupidjshparam table.

The useridjshparam column adds "useridjshparam" to the SELECT clause of the view to be prepared and returns the data owner account.
(View name) In the $ jgroupidjshparam table, store the group ID of the group to which the data belongs.The group ID uses the primary key jgroupid of the jgroup table.

It is a good idea to use xxxx $ jgroupidjshparam table in another model and refer to this.
(View name) You can also prepare the $ jgroupidjshparam table as a view, not actually a table.
The group authority controls browsing/updating by specifying the narrowing condition in the WHERE clause.Since the narrowing part of the WHERE clause is automatically generated by the Wagby side, it works by preparing the useridjshparam column and xxxx $ jgroupidjshparam.

Handling of mandatory items

In the model defined by Wagby as "Required", please check whether NULL actually exists on the view side.Since Wagby assumes that NULL does not exist in essential items, if NULL is found, data can not be acquired correctly and an error will result.