Skip to content

Commit 7b442b9

Browse files
ian-wdiBotPeaches
andauthored
Realm JS v11.0.0 upgrade (#9)
* build: drop node 14.x * feat: init realm v11.x upgrade * build: set workflow CI env to true Co-authored-by: Connor Tumbleson <[email protected]>
1 parent 17ae5fa commit 7b442b9

File tree

5 files changed

+44
-52
lines changed

5 files changed

+44
-52
lines changed

.github/workflows/build.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: Node.js CI
22
on: push
3+
env:
4+
CI: true
35

46
jobs:
57
build:
68
runs-on: ubuntu-latest
79
strategy:
810
matrix:
9-
node-version: [14.x, 16.x, 18.x]
11+
node-version: [16.x, 18.x]
1012

1113
steps:
1214
- uses: actions/checkout@v3

config/Database.js

+14-30
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,21 @@
44
import { Config } from './config';
55
import Realm from 'realm';
66

7-
class JobSchema {
8-
static schema = {
9-
name: 'Job',
10-
primaryKey: 'id',
11-
properties: {
12-
id: 'string', // UUID.
13-
name: 'string', // Job name to be matched with worker function.
14-
payload: 'string', // Job payload stored as JSON.
15-
data: 'string', // Store arbitrary data like "failed attempts" as JSON.
16-
priority: 'int', // -5 to 5 to indicate low to high priority.
17-
active: { type: 'bool', default: false}, // Whether or not job is currently being processed.
18-
timeout: 'int', // Job timeout in ms. 0 means no timeout.
19-
created: 'date', // Job creation timestamp.
20-
failed: 'date?' // Job failure timestamp (null until failure).
21-
}
22-
};
23-
24-
get values() {
25-
return {
26-
id: this.id,
27-
name: this.name,
28-
payload: this.payload,
29-
data: this.data,
30-
priority: this.priority,
31-
active: this.active,
32-
timeout: this.timeout,
33-
created: this.created,
34-
failed: this.failed
35-
};
7+
const JobSchema = {
8+
name: 'Job',
9+
primaryKey: 'id',
10+
properties: {
11+
id: 'string', // UUID.
12+
name: 'string', // Job name to be matched with worker function.
13+
payload: 'string', // Job payload stored as JSON.
14+
data: 'string', // Store arbitrary data like "failed attempts" as JSON.
15+
priority: 'int', // -5 to 5 to indicate low to high priority.
16+
active: { type: 'bool', default: false}, // Whether or not job is currently being processed.
17+
timeout: 'int', // Job timeout in ms. 0 means no timeout.
18+
created: 'date', // Job creation timestamp.
19+
failed: 'date?' // Job failure timestamp (null until failure).
3620
}
37-
}
21+
};
3822

3923
export default class Database {
4024
static realmInstance = null; // Use a singleton connection to realm for performance.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dependencies": {
2828
"promise-reflect": "^1.1.0",
2929
"react-native-uuid": "^2.0.1",
30-
"realm": "^10.21.1"
30+
"realm": "^11.0.0"
3131
},
3232
"devDependencies": {
3333
"@babel/core": "^7.17.9",

tests/Queue.test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,11 @@ describe('Models/Queue', function() {
731731

732732
const jobs = await queue.getJobs(true);
733733

734+
const jobTest = JSON.stringify(jobs[0]);
735+
const jobParsed = JSON.parse(jobTest);
736+
734737
// Check job has default values.
735-
jobs[0].should.have.properties({
738+
jobParsed.should.have.properties({
736739
name: jobName,
737740
payload: JSON.stringify({}),
738741
data: JSON.stringify({attempts: 1}),
@@ -755,8 +758,10 @@ describe('Models/Queue', function() {
755758
queue.status.should.equal('inactive');
756759

757760
const jobs = await queue.getJobs(true);
761+
const jobTest = JSON.stringify(jobs[0]);
762+
const parsedJob = JSON.parse(jobTest);
758763

759-
jobs[0].should.have.properties({
764+
parsedJob.should.have.properties({
760765
name: jobName,
761766
payload: JSON.stringify(payload),
762767
data: JSON.stringify({attempts: jobOptions.attempts}),

yarn.lock

+19-18
Original file line numberDiff line numberDiff line change
@@ -1595,10 +1595,19 @@
15951595
"@jridgewell/resolve-uri" "^3.0.3"
15961596
"@jridgewell/sourcemap-codec" "^1.4.10"
15971597

1598-
"@realm.io/common@^0.1.4":
1599-
version "0.1.5"
1600-
resolved "https://registry.yarnpkg.com/@realm.io/common/-/common-0.1.5.tgz#4285c8142d5024a0876318cdfd28f23ea98ebf4f"
1601-
integrity sha512-Y+UnICLvsPFpe2WOXWIdJUaV3G2qDocN8al/Yz13mYMkjODXHL4VhyfEKR2hvcAubv+7isdegEyYNdo3zQzbFA==
1598+
"@realm/common@^0.1.4":
1599+
version "0.1.4"
1600+
resolved "https://registry.yarnpkg.com/@realm/common/-/common-0.1.4.tgz#48ff628a22b27c61ba886caff395909632240927"
1601+
integrity sha512-bKpIRZIQ4ykribFi0igCwuvf7P4+Ex2XYKqDw1JDe6sCGAaPMwhazooyM6h32fUjtXRTbdAWH2S9JH8Xh/LrqQ==
1602+
1603+
"@realm/network-transport@^0.7.2":
1604+
version "0.7.2"
1605+
resolved "https://registry.yarnpkg.com/@realm/network-transport/-/network-transport-0.7.2.tgz#167b85fd4744b66d9e37d096e1e9e2720d7abd26"
1606+
integrity sha512-IZ6yd+mGOYvSMVEVFf/v5qtZOi8bk4ZBxoj25GNQFyeFKxOs1WH+z4IDZscMC2GhQ4hdmI3Sg+RUEphimtHupQ==
1607+
dependencies:
1608+
"@realm/common" "^0.1.4"
1609+
abort-controller "^3.0.0"
1610+
node-fetch "^2.6.0"
16021611

16031612
"@sinclair/typebox@^0.23.3":
16041613
version "0.23.4"
@@ -4214,20 +4223,13 @@ readable-stream@^3.1.1, readable-stream@^3.4.0:
42144223
string_decoder "^1.1.1"
42154224
util-deprecate "^1.0.1"
42164225

4217-
realm-network-transport@^0.7.2:
4218-
version "0.7.2"
4219-
resolved "https://registry.yarnpkg.com/realm-network-transport/-/realm-network-transport-0.7.2.tgz#382b965bf97a4132e0f8770f864d4a20d976be35"
4220-
integrity sha512-/5/YtZ5+ZIHIPgVFL6fRyx0/FRhmMaaF7L/h+iU8VKWGzesiBusSaeInosrM6v8MQvsW3W9ApBCeUwNW6m+8sg==
4221-
dependencies:
4222-
abort-controller "^3.0.0"
4223-
node-fetch "^2.6.0"
4224-
4225-
realm@^10.21.1:
4226-
version "10.21.1"
4227-
resolved "https://registry.yarnpkg.com/realm/-/realm-10.21.1.tgz#4432de92dae4d070c3203000a86a6421cf1a8cc6"
4228-
integrity sha512-I+QzOEw478LGPxgSLvF3YlsMCwRNe4d35uKB77tg2rARDYVtq4pW/XVfbvPrJnwPpgJR53stHmkspj0xvJgFUw==
4226+
realm@^11.0.0:
4227+
version "11.0.0"
4228+
resolved "https://registry.yarnpkg.com/realm/-/realm-11.0.0.tgz#04b989fbc9b3974d1447e634f416c22da1ed698b"
4229+
integrity sha512-ENIK8IgY0LKCSShg1cKlXF4ALQwf2EdNi/eSQmLiXOa9i3H2aG942ouZ0Dtd26SNzkAEwwvDmKmGOOR332g+qQ==
42294230
dependencies:
4230-
"@realm.io/common" "^0.1.4"
4231+
"@realm/common" "^0.1.4"
4232+
"@realm/network-transport" "^0.7.2"
42314233
bindings "^1.5.0"
42324234
bson "4.4.1"
42334235
command-line-args "^5.1.1"
@@ -4240,7 +4242,6 @@ realm@^10.21.1:
42404242
prebuild-install "^7.0.1"
42414243
progress "^2.0.3"
42424244
prop-types "^15.6.2"
4243-
realm-network-transport "^0.7.2"
42444245
request "^2.88.0"
42454246
stream-counter "^1.0.0"
42464247
sync-request "^3.0.1"

0 commit comments

Comments
 (0)