Module: Views

Defined in:
lib/jungle_path/app/schemas/views.rb

Class Method Summary collapse

Class Method Details

.filter_contactObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jungle_path/app/schemas/views.rb', line 5

def self.filter_contact
	@filter_contact = JunglePath::DBModel::View.new(
		JunglePath::SQL::Helpers.sql("
			create or replace function filter_contact(p_contact_id int)
			returns table (
			  id int,
			  name text,
			  email text,
				user_id int,
			  created_at timestamp,
			  created_by_user_id int,
			  updated_at timestamp,
			  updated_by_user_id int
			)
			as
			$body$
				select
					a.*
				from contact a
				where a.id = p_contact_id
			$body$
			language sql;
		"),
		"drop function filter_contact(int)",
		[:contact],
		[:contact_id]
	) unless @filter_contact
	@filter_contact
end

.filter_testObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/jungle_path/app/schemas/views.rb', line 35

def self.filter_test
	@filter_test = JunglePath::DBModel::View.new(
		JunglePath::SQL::Helpers.sql("
			create or replace function filter_test(p_contact_id int)
			returns table (
			  id int,
			  name text,
			  email text,
				user_id int,
			  created_at timestamp,
			  created_by_user_id int,
			  updated_at timestamp,
			  updated_by_user_id int
			)
			as
			$body$
				select
					a.*
				from contact a
				where a.id = p_contact_id
			$body$
			language sql;
		"),
		"drop function filter_test(int)",
		[:contact, :test],
		[:contact_id]
	) unless @filter_test
	@filter_test
end