Skip to content

Commit

Permalink
Inject task_status config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kabirbaidhya committed Feb 5, 2020
1 parent 5da4611 commit 44ddfd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
--
CREATE PROCEDURE [testdata].setup_data(
@create_admin BIT = 0,
@admin_email VARCHAR(100) = NULL
@admin_email VARCHAR(100) = NULL,
@task_status VARCHAR(100) = NULL
)
AS
BEGIN
Expand Down Expand Up @@ -68,4 +69,11 @@ BEGIN
) AS t(user_email, title, description, is_complete)
INNER JOIN dbo.users u ON u.email = t.user_email

-- Update status according to the @task_status flag.
IF (@task_status = 'all_complete')
UPDATE dbo.tasks SET is_complete = 1;

IF (@task_status = 'none_complete')
UPDATE dbo.tasks SET is_complete = 0;

END
4 changes: 3 additions & 1 deletion examples/node-app-mssql/src/sql/scripts/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
--
DECLARE @create_admin BIT;
DECLARE @admin_email VARCHAR(100);
DECLARE @task_status VARCHAR(100);

SET @create_admin = (SELECT IIF([value] = 'true', 1, 0) FROM __injected_config WHERE [key] = 'create_admin');
SET @admin_email = (SELECT [value] FROM __injected_config WHERE [key] = 'admin_email');
SET @task_status = (SELECT [value] FROM __injected_config WHERE [key] = 'task_status');

-- Setup data.
EXEC testdata.setup_data @create_admin, @admin_email;
EXEC testdata.setup_data @create_admin, @admin_email, @task_status;

0 comments on commit 44ddfd2

Please sign in to comment.