# Class View

View Class

#### Implements

- AbstractView

- Defined in packages/saltcorn-data/models/view.ts:61
- Defined in packages/saltcorn-data/models/view.ts:1012

##### Index

### Constructors

constructor

### Properties

attributes?
configuration?
default_render_page?
description?
exttable_name?
id?
min_role
name
singleton?
slug?
table?
table_id?
table_name?
viewtemplate
viewtemplateObj?

### Accessors

menu_label
select_option

### Methods

authorise_get
authorise_post
check_viewtemplate
clone
combine_state_and_default_state
connected_objects
delete
emitRealTimeEvent
get_config_flow
get_state_fields
getRealTimeEventName
getStringsForI18n
getTags
inbound_connected_objects
interpolate_title_string
isRemoteTable
openDataStream
queries
renderLocally
rewrite_query_from_slug
run
run_possibly_on_page
runMany
runPost
runRoute
runServerSide
create
delete
find
find_all_views_where
find_possible_links_to_table
find_table_views_where
findOne
state_refresh
update

## Constructors

### constructor

- new View(o: View | ViewCfg): View

  View constructor

  #### Parameters

  - o: View | ViewCfg

  #### Returns View

  - Defined in packages/saltcorn-data/models/view.ts:82

## Properties

### `Optional` attributes

attributes?: any

Implementation of AbstractView.attributes

- Defined in packages/saltcorn-data/models/view.ts:73

### `Optional` configuration

configuration?: any

Implementation of AbstractView.configuration

- Defined in packages/saltcorn-data/models/view.ts:72

### `Optional` default_render_page

default_render_page?: string

- Defined in packages/saltcorn-data/models/view.ts:68

### `Optional` description

description?: string

- Defined in packages/saltcorn-data/models/view.ts:70

### `Optional` exttable_name

exttable_name?: string

- Defined in packages/saltcorn-data/models/view.ts:69

### `Optional` id

id?: number

Implementation of AbstractView.id

- Defined in packages/saltcorn-data/models/view.ts:63

### min_role

min_role: number

Implementation of AbstractView.min_role

- Defined in packages/saltcorn-data/models/view.ts:66

### name

name: string

Implementation of AbstractView.name

- Defined in packages/saltcorn-data/models/view.ts:62

### `Optional` singleton

singleton?: boolean

- Defined in packages/saltcorn-data/models/view.ts:75

### `Optional` slug

slug?: any

- Defined in packages/saltcorn-data/models/view.ts:76

### `Optional` table

table?: AbstractTable

- Defined in packages/saltcorn-data/models/view.ts:74

### `Optional` table_id

table_id?: number

- Defined in packages/saltcorn-data/models/view.ts:64

### `Optional` table_name

table_name?: string

Implementation of AbstractView.table_name

- Defined in packages/saltcorn-data/models/view.ts:71

### viewtemplate

viewtemplate: string

Implementation of AbstractView.viewtemplate

- Defined in packages/saltcorn-data/models/view.ts:65

### `Optional` viewtemplateObj

viewtemplateObj?: ViewTemplate

- Defined in packages/saltcorn-data/models/view.ts:67

## Accessors

### menu_label

- Get menu label

  #### Returns string | undefined

  - Defined in packages/saltcorn-data/models/view.ts:203

### select_option

- get select_option(): any

  #### Returns any

  - Defined in packages/saltcorn-data/models/view.ts:252

## Methods

### authorise_get

- authorise_get(
  arg: { query: any; req: any; table_id: number },
  remote?: boolean,
  ): Promise<boolean>

  #### Parameters

  - arg: { query: any; req: any; table_id: number }
  - remote: boolean = false

  #### Returns Promise<boolean>

  - Defined in packages/saltcorn-data/models/view.ts:439

### authorise_post

- authorise_post(
  arg: { body: any; req: any; table_id: number },
  remote?: boolean,
  ): Promise<boolean>

  #### Parameters

  - arg: { body: any; req: any; table_id: number }
  - remote: boolean = false

  #### Returns Promise<boolean>

  - Defined in packages/saltcorn-data/models/view.ts:405

### check_viewtemplate

- check_viewtemplate(): void

  #### Returns void

  #### Throws

  - Defined in packages/saltcorn-data/models/view.ts:577

### clone

- clone(): Promise<View>

  Clone View

  #### Returns Promise<View>

  - Defined in packages/saltcorn-data/models/view.ts:330

### combine_state_and_default_state

- combine_state_and_default_state(req_query: any): any

  #### Parameters

  - req_query: any

  #### Returns any

  - Defined in packages/saltcorn-data/models/view.ts:823

### connected_objects

- connected_objects(): Promise<ConnectedObjects>

  #### Returns Promise<ConnectedObjects>

  Implementation of AbstractView.connected_objects

  - Defined in packages/saltcorn-data/models/view.ts:925

### delete

- delete(): Promise<void>

  Delete current view from db

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/view.ts:353

### emitRealTimeEvent

- emitRealTimeEvent(eventType: string, data: any): void

  emit a Real-time collaboration event for this view.

  #### Parameters

  - eventType: string

    event without view name (e.g. "DROP_EVENT")

  - data: any

    object you want to get in the event handler

  #### Returns void

  - Defined in packages/saltcorn-data/models/view.ts:973

### get_config_flow

- get_config_flow(req: any): Promise<Workflow>

  #### Parameters

  - req: any

  #### Returns Promise<Workflow>

  - Defined in packages/saltcorn-data/models/view.ts:846

### get_state_fields

- get_state_fields(): Promise<FieldLike[]>

  #### Returns Promise<FieldLike[]>

  - Defined in packages/saltcorn-data/models/view.ts:180

### getRealTimeEventName

- getRealTimeEventName(eventType: string): string

  get event name with view name in it (e.g. DROP_EVENT_my_kanban_view).

  #### Parameters

  - eventType: string

    event without view name (e.g. "DROP_EVENT")

  #### Returns string

  the full event name

  - Defined in packages/saltcorn-data/models/view.ts:985

### getStringsForI18n

- getStringsForI18n(): string[]

  #### Returns string[]

  - Defined in packages/saltcorn-data/models/view.ts:457

### getTags

- getTags(): Promise<AbstractTag[]>

  get all tags associated with this view

  #### Returns Promise<AbstractTag[]>

  a promise with the tags

  Implementation of AbstractView.getTags

  - Defined in packages/saltcorn-data/models/view.ts:963

### inbound_connected_objects

- inbound_connected_objects(): Promise<ConnectedObjects>

  #### Returns Promise<ConnectedObjects>

  - Defined in packages/saltcorn-data/models/view.ts:906

### interpolate_title_string

- interpolate_title_string(title: string, query: any): Promise<string>

  #### Parameters

  - title: string
  - query: any

  #### Returns Promise<string>

  - Defined in packages/saltcorn-data/models/view.ts:425

### isRemoteTable

- isRemoteTable(): boolean

  saltcorn-mobile-app helper. Check if the table of a view is local or server-side

  #### Returns boolean

  true if server-side table

  - Defined in packages/saltcorn-data/models/view.ts:950

### openDataStream

- openDataStream(
  id: number | undefined,
  fieldName: string,
  fieldView: string,
  user: any,
  targetOpts: any,
  ): Promise<any>

  #### Parameters

  - id: number | undefined
  - fieldName: string
  - fieldView: string
  - user: any
  - targetOpts: any

  #### Returns Promise<any>

  - Defined in packages/saltcorn-data/models/view.ts:796

### queries

- queries(remote?: boolean, req?: Req, res?: any): any

  #### Parameters

  - `Optional` remote: boolean
  - `Optional` req: Req
  - `Optional` res: any

  #### Returns any

  - Defined in packages/saltcorn-data/models/view.ts:518

### renderLocally

- renderLocally(): boolean

  Should we render on the local machine or get it from a server? In the normal web mode it's always the server but on mobile, we can render on the device as well

  #### Returns boolean

  - Defined in packages/saltcorn-data/models/view.ts:993

### rewrite_query_from_slug

- rewrite_query_from_slug(query: any, params: any): void

  #### Parameters

  - query: any
  - params: any

  #### Returns void

  - Defined in packages/saltcorn-data/models/view.ts:889

### run

- run(query: any, extraArgs: RunExtra, remote?: boolean): Promise<any>

  Run (Execute) View

  #### Parameters

  - query: any
  - extraArgs: RunExtra
  - remote: boolean = ...

  #### Returns Promise<any>

  - Defined in packages/saltcorn-data/models/view.ts:486

### run_possibly_on_page

- run_possibly_on_page(
  query: any,
  req: Req,
  res: Res,
  remote?: boolean,
  extra?: any,
  ): Promise<string | { goto?: string }>

  #### Parameters

  - query: any
  - req: Req
  - res: Res
  - remote: boolean = false
  - extra: any = {}

  #### Returns Promise<string | { goto?: string }>

  - Defined in packages/saltcorn-data/models/view.ts:591

### runMany

- runMany(
  query: GenObj,
  extraArgs: RunExtra,
  remote?: boolean,
  ): Promise<string[] | { html: string; row: any }[]>

  Run many views with content filtered by query. Used in Search for example

  #### Parameters

  - query: GenObj

    this is query string

  - extraArgs: RunExtra
  - `Optional` remote: boolean

  #### Returns Promise<string[] | { html: string; row: any }[]>

  #### Throws

  - Defined in packages/saltcorn-data/models/view.ts:634

### runPost

- runPost(
  query: GenObj,
  body: GenObj,
  extraArgs: RunExtra,
  remote?: boolean,
  ): Promise<any>

  #### Parameters

  - query: GenObj
  - body: GenObj
  - extraArgs: RunExtra
  - remote: boolean = ...

  #### Returns Promise<any>

  - Defined in packages/saltcorn-data/models/view.ts:708

### runRoute

- runRoute(
  route: string,
  body: any,
  res: Res,
  extraArgs: RunExtra,
  remote?: boolean,
  ): Promise<any>

  #### Parameters

  - route: string
  - body: any
  - res: Res
  - extraArgs: RunExtra
  - remote: boolean = false

  #### Returns Promise<any>

  - Defined in packages/saltcorn-data/models/view.ts:760

### runServerSide

- runServerSide(query: any): Promise<string>

  #### Parameters

  - query: any

  #### Returns Promise<string>

  - Defined in packages/saltcorn-data/models/view.ts:471

### `Static` create

- create(v: ViewCfg): Promise<View>

  Create view in database

  #### Parameters

  - v: ViewCfg

  #### Returns Promise<View>

  - Defined in packages/saltcorn-data/models/view.ts:311

### `Static` delete

- delete(where: Where): Promise<void>

  Delete list of views

  #### Parameters

  - where: Where

    condition

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/view.ts:381

### `Static` find

- find(where?: Where, selectopts?: SelectOptions): Promise<View[]>

  #### Parameters

  - `Optional` where: Where
  - selectopts: SelectOptions = ...

  #### Returns Promise<View[]>

  - Defined in packages/saltcorn-data/models/view.ts:137

### `Static` find_all_views_where

- find_all_views_where(pred: FindViewsPred): Promise<View[]>

  #### Parameters

  - pred: FindViewsPred

  #### Returns Promise<View[]>

  - Defined in packages/saltcorn-data/models/view.ts:271

### `Static` find_possible_links_to_table

- find_possible_links_to_table(table: string | number | Tablely): Promise<View[]>

  #### Parameters

  - table: string | number | Tablely

  #### Returns Promise<View[]>

  - Defined in packages/saltcorn-data/models/view.ts:295

### `Static` find_table_views_where

- find_table_views_where(
  table: string | number | Tablely,
  pred: FindViewsPred,
  ): Promise<View[]>

  #### Parameters

  - table: string | number | Tablely
  - pred: FindViewsPred

  #### Returns Promise<View[]>

  - Defined in packages/saltcorn-data/models/view.ts:215

### `Static` findOne

- findOne(where: Where): View | undefined

  #### Parameters

  - where: Where

  #### Returns View | undefined

  - Defined in packages/saltcorn-data/models/view.ts:118

### `Static` state_refresh

- state_refresh(): Promise<void>

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/view.ts:195

### `Static` update

- update(v: any, id: number): Promise<void>

  Update View description

  #### Parameters

  - v: any

    view name

  - id: number

    id

  #### Returns Promise<void>

  - Defined in packages/saltcorn-data/models/view.ts:392