Skip to content

Class: RealmSession ​

Defined in: src/realm-session.ts:26

A guarded Realm handle used by the high-level API.

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession
return session.isOpen

Constructors ​

new RealmSession(instance, readOnly, onWrite?): RealmSession

Defined in: src/realm-session.ts:29

Parameters ​

ParameterType
instanceRealm
readOnlyboolean
onWrite?() => void

Returns ​

RealmSession

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession

return session.isOpen

Accessors ​

isOpen ​

get isOpen(): boolean

Defined in: src/realm-session.ts:36

Whether the underlying Realm connection is still open.

Returns ​

boolean

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession

return session.isOpen

raw ​

get raw(): Realm

Defined in: src/realm-session.ts:52

Returns the raw Realm instance.

Mutations bypass file and hash checks. Use a write transaction. Prefer SkinEditor, BeatmapSetEditor, ScoreEditor, and OwnedFileEditor.

Returns ​

Realm

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession

return session.isOpen

Methods ​

assertOpen() ​

assertOpen(): void

Defined in: src/realm-session.ts:99

Returns ​

void

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession

return session.isOpen

close() ​

close(): void

Defined in: src/realm-session.ts:93

Closes the Realm connection. Calling this more than once is safe.

Returns ​

void

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession

return session.isOpen

read() ​

read<T>(action): T

Defined in: src/realm-session.ts:67

Runs a read callback over raw Realm objects.

The callback receives mutable Realm-owned objects. Changes are not synchronized.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
action(realm) => T

Returns ​

T

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession
return session.read(realm => realm.objects('Score').length)

write() ​

write<T>(action): T

Defined in: src/realm-session.ts:84

Runs a write callback over raw Realm objects.

The callback receives mutable Realm-owned objects. Keep hashes and file references valid. Prefer SkinEditor, BeatmapSetEditor, ScoreEditor, and OwnedFileEditor.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
action(realm) => T

Returns ​

T

This example requires Node.js.

ts
import type { RealmSession } from 'osu-files'

const session = {} as RealmSession
return session.write(realm => realm.objects('Score').length)

Released under the MIT License.