File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ from datetime import datetime
2
2
import random
3
3
4
4
class ID:
5
- // Generate a unique ID based on timestamp
6
- // Recreated from https://www.php.net/manual/en/function.uniqid.php
5
+ # Generate a unique ID based on timestamp
6
+ # Recreated from https://www.php.net/manual/en/function.uniqid.php
7
7
@staticmethod
8
8
def __uniqueId():
9
9
now = datetime.now()
@@ -16,8 +16,8 @@ class ID:
16
16
def custom(id):
17
17
return id
18
18
19
- // Generate a unique ID with padding to have a longer ID
20
- // Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
19
+ # Generate a unique ID with padding to have a longer ID
20
+ # Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
21
21
@staticmethod
22
22
def unique(padding = 7):
23
23
base_id = ID.__uniqueId()
Original file line number Diff line number Diff line change 1
1
require 'securerandom'
2
2
3
- // Generate a unique ID based on timestamp
4
- // Recreated from https://www.php.net/manual/en/function.uniqid.php
3
+ # Generate a unique ID based on timestamp
4
+ # Recreated from https://www.php.net/manual/en/function.uniqid.php
5
5
def uniqueId
6
6
now = Time.now
7
7
seconds_since_epoch = now.to_i
@@ -16,6 +16,8 @@ module {{spec.title | caseUcfirst}}
16
16
id
17
17
end
18
18
19
+ # Generate a unique ID with padding to have a longer ID
20
+ # Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
19
21
def self.unique(padding=7)
20
22
base_id = uniqueId
21
23
random_padding = SecureRandom.hex(padding)
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ public class ID {
19
19
// Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
20
20
public static func unique(padding: Int = 7) -> String {
21
21
let baseId = uniqueId()
22
- let randomPadding = (1...padding).map {
23
- String(format: "%x", Int.random(in: 0..<16 ))
22
+ let randomPadding = (1...padding).map {
23
+ _ in String(format: "%x", Int.random(in: 0..<16 ))
24
24
}.joined ()
25
25
return baseId + randomPadding
26
26
}
You can’t perform that action at this time.
0 commit comments