0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ローコードのSKE】更新日時による排他処理

Last updated at Posted at 2025-04-12

今回の記事は、SKEで排他処理を実装するサンプルです。

共通設定

以下のテーブルを利用して、サンプルを作成します。

CREATE TABLE "テストテーブル"
(
  "主キー" integer NOT NULL,
  "名称" character varying(10),
  "作成者" character varying(20),
  "作成日時" timestamp without time zone,
  "最終更新者" character varying(20),
  "最終更新日時" timestamp without time zone,
  CONSTRAINT "テストテーブル_pkey" PRIMARY KEY ("主キー")
)

排他用項目は値の表示用フォーマットを行うと更新前後の比較はうまくできないため、表示用と排他用別々にする必要です。このため、クエリ項目を作成します。また、作成者、更新者、作成日時、更新日時は自動的に登録されるように設定します。

image.png

クエリ
select *,最終更新日時 as v更新日時 from テストテーブル
作成者
{
	"add": function(){
        return session.get("USER_ID");
    },
	"copyAdd": function(){
        return session.get("USER_ID");
    }
}
作成日時
{
	"add": function(){
        return new Date();
    },
	"copyAdd": function(){
        return new Date();
    }
}
最終更新者
{
	"add": function(){
        return session.get("USER_ID");
    },
	"copyAdd": function(){
        return session.get("USER_ID");
    },
	"edit": function(){
        return session.get("USER_ID");
    }
}
最終更新日時
{
	"add": function(){
        return new Date();
    },
	"copyAdd": function(){
        return new Date();
    },
	"edit": function(){
        return new Date();
    }
}

入力ダイアログ

タイトル「最終更新日時」の項目は表示用で、ビュー項目とリンクします。タイトル「排他用」はhiddenにして、テーブル項目とリンクします。
image.png

効果

2つのブラウザで同じデータを開きます。
image.png
まず右の画面を保存すると、保存に成功します。次に左の画面を保存すると、排他により保存失敗します。
image.png

まとめ

今回の記事のサンプルには、以下のアドオンを利用しました。

  • モード別項目設定値のアドオン
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?