• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

node-casbin / sequelize-adapter / 5358173782

pending completion
5358173782

Pull #80

github

web-flow
Merge a3d8655a4 into 1724f2e17
Pull Request #80: fix: create new CasbinRule instance every time sequelize Adapter opens connection

25 of 39 branches covered (64.1%)

Branch coverage included in aggregate %.

14 of 14 new or added lines in 2 files covered. (100.0%)

117 of 126 relevant lines covered (92.86%)

6.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/casbinRule.ts
1
// Copyright 2018 The Casbin Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
import {
1✔
16
  Table,
17
  Column,
18
  Model,
19
  getOptions,
20
  setOptions,
21
} from 'sequelize-typescript';
22

23
@Table({ timestamps: false })
24
export class CasbinRule extends Model<CasbinRule> {
1✔
25
  @Column
1✔
26
  public ptype: string;
27

28
  @Column
1✔
29
  public v0: string;
30

31
  @Column
1✔
32
  public v1: string;
33

34
  @Column
1✔
35
  public v2: string;
36

37
  @Column
1✔
38
  public v3: string;
39

40
  @Column
1✔
41
  public v4: string;
42

43
  @Column
1✔
44
  public v5: string;
45
}
46

47
export function createCasbinRule(
1✔
48
  tableName = 'casbin_rule',
×
49
  schema?: string
50
): typeof CasbinRule {
51
  class CustomCasbinRule extends CasbinRule {}
52

53
  const options = getOptions(CustomCasbinRule.prototype);
1✔
54
  options!.tableName = tableName;
1✔
55
  options!.schema = schema;
1✔
56
  setOptions(CustomCasbinRule.prototype, options!);
1✔
57

58
  return CustomCasbinRule;
1✔
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc