Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Latest commit

 

History

History
454 lines (281 loc) · 12.4 KB

_sdbsubdoc_.sdbsubdoc.md

File metadata and controls

454 lines (281 loc) · 12.4 KB

sdb-tsGlobals"SDBSubDoc"SDBSubDoc

Class: SDBSubDoc <E>

Type parameters

E

Hierarchy

Index

Constructors

Methods

Constructors

constructor

+ new SDBSubDoc(doc: SDBDoc‹any›, path: ShareDB.Path): SDBSubDoc

Overrides OpSubmittable.constructor

Defined in SDBSubDoc.ts:7

Parameters:

Name Type
doc SDBDoc‹any›
path ShareDB.Path

Returns: SDBSubDoc

Methods

Protected doSubmitOp

doSubmitOp(ops: ReadonlyArray‹ShareDB.Op›, source: any): Promise‹this›

Overrides OpSubmittable.doSubmitOp

Defined in SDBSubDoc.ts:78

Submit a raw series of ShareDB operations. Note that all paths should be relative to this subdoc

Parameters:

Name Type Default Description
ops ReadonlyArray‹ShareDB.Op› - The raw operations
source any true (optional) the change source

Returns: Promise‹this›


getData

getData(): E | null

Defined in SDBSubDoc.ts:65

Get the data in this sub-document

Returns: E | null


submitListDeleteOp

submitListDeleteOp(p: ShareDB.Path, ld: any): Promise‹this›

Inherited from OpSubmittable.submitListDeleteOp

Defined in OpSubmittable.ts:96

Remove an item from a list

doc.submitListDeleteOp(['lst', 2]);

is analogous to

obj.lst.splice(2, 1);

Parameters:

Name Type Default Description
p ShareDB.Path - The path array
ld any this.traverse(p) The object to delete. Leave this unspecified.

Returns: Promise‹this›

A promise that resolve to this


submitListInsertOp

submitListInsertOp(p: ShareDB.Path, li: any): Promise‹this›

Inherited from OpSubmittable.submitListInsertOp

Defined in OpSubmittable.ts:81

Insert an item into a list

doc.submitListInsert(['lst', 0], 'item');

is analogous to

obj.lst[0] = 'item';

Parameters:

Name Type Description
p ShareDB.Path The path array
li any The object to insert.

Returns: Promise‹this›

A promise that resolve to this


submitListPushOp

submitListPushOp(p: ShareDB.Path, ...items: Array‹any›): Promise‹this›

Inherited from OpSubmittable.submitListPushOp

Defined in OpSubmittable.ts:146

Push any number of items to the end of the list.

Parameters:

Name Type Description
p ShareDB.Path The path array
...items Array‹any› The items to add to the end of the list

Returns: Promise‹this›


submitListReplaceOp

submitListReplaceOp(p: ShareDB.Path, li: any, ld: any): Promise‹this›

Inherited from OpSubmittable.submitListReplaceOp

Defined in OpSubmittable.ts:66

Replace an item in a list

doc.submitListReplaceOp(['lst', 0], 'item');

is analogous to

obj.lst[0] = 'item';

Parameters:

Name Type Default Description
p ShareDB.Path - The path array
li any - The object to insert.
ld any this.traverse(p) The object to remove. Leave this unspecified.

Returns: Promise‹this›

A promise that resolve to this


submitListSpliceOp

submitListSpliceOp(p: ShareDB.Path, index: number, numToRemove: number, ...toAdd: Array‹any›): Promise‹this›

Inherited from OpSubmittable.submitListSpliceOp

Defined in OpSubmittable.ts:122

Perform a JavaScript splice operation

Parameters:

Name Type Description
p ShareDB.Path The path array
index number Index at which to start changing the array (with origin 0).
numToRemove number An integer indicating the number of old array elements to remove.
...toAdd Array‹any› The elements to add to the array, beginning at index.

Returns: Promise‹this›


submitListUnshiftOp

submitListUnshiftOp(p: ShareDB.Path, ...items: Array‹any›): Promise‹this›

Inherited from OpSubmittable.submitListUnshiftOp

Defined in OpSubmittable.ts:159

Add any number of items to the beginning of a list

Parameters:

Name Type Description
p ShareDB.Path The path array
...items Array‹any› The items to add to the beginning of the list

Returns: Promise‹this›


submitNumberAddOp

submitNumberAddOp(p: ShareDB.Path, na: number): Promise‹this›

Inherited from OpSubmittable.submitNumberAddOp

Defined in OpSubmittable.ts:112

Increment a number

doc.submitNumberAddOp(['prop1', 'x'], 4);

is analogous to

obj.prop1.x += 4;

Parameters:

Name Type Description
p ShareDB.Path The path array
na number The number to increment by

Returns: Promise‹this›

A promise that resolve to this


submitObjectDeleteOp

submitObjectDeleteOp(p: ShareDB.Path, od: any): Promise‹this›

Inherited from OpSubmittable.submitObjectDeleteOp

Defined in OpSubmittable.ts:50

Delete an object property.

doc.submitObjectDeleteOp(['prop1', 'x']);

is analogous to

delete obj.prop1.x;

Parameters:

Name Type Default Description
p ShareDB.Path - The path array
od any this.traverse(p) (optional) The object to delete. Leave this unspecified.

Returns: Promise‹this›

A promise that resolve to this


submitObjectInsertOp

submitObjectInsertOp(p: ShareDB.Path, oi: any): Promise‹this›

Inherited from OpSubmittable.submitObjectInsertOp

Defined in OpSubmittable.ts:35

Insert within an object (if the property does not have a value).

doc.submitObjectInsertOp(['prop1', 'x'], 'value');

is analogous to

obj.prop1.x = 'value';

Parameters:

Name Type Description
p ShareDB.Path The path array
oi any The object to insert

Returns: Promise‹this›

A promise that resolve to this


submitObjectReplaceOp

submitObjectReplaceOp(p: ShareDB.Path, oi: any, od: any): Promise‹this›

Inherited from OpSubmittable.submitObjectReplaceOp

Defined in OpSubmittable.ts:20

Replace within an object (if the property already has a value).

doc.submitObjectReplaceOp(['prop1', 'x'], 'value');

is analogous to

obj.prop1.x = 'value';

Parameters:

Name Type Default Description
p ShareDB.Path - The path array
oi any - The object to insert
od any this.traverse(p) (optional) The object to remove. Leave this unspecified

Returns: Promise‹this›

A promise that resolve to this


submitOp

submitOp(ops: ReadonlyArray‹ShareDB.Op›, source?: any): Promise‹this›

Inherited from OpSubmittable.submitOp

Defined in OpSubmittable.ts:169

Submit a series of ShareDB operations

Parameters:

Name Type Description
ops ReadonlyArray‹ShareDB.Op› The raw operations
source? any (optional) the change source

Returns: Promise‹this›


subscribe

subscribe(callback: Subscriber‹E›): Promise‹void›

Defined in SDBSubDoc.ts:22

Signal that we want to listen to changes in this sub-document. Note that we don't fetch new versions unless the document is being subscribed to

Parameters:

Name Type Default
callback Subscriber‹E› ()=>null

Returns: Promise‹void›

a promise that resolves when we have an initial snapshot of the sub-document


traverse

traverse(path: ShareDB.Path): any

Overrides OpSubmittable.traverse

Defined in SDBSubDoc.ts:87

Get the value at a given location in the document. Note that this is relative to this subdocument

Parameters:

Name Type Description
path ShareDB.Path The path array

Returns: any


unsubscribe

unsubscribe(callback: Subscriber‹E›): void

Defined in SDBSubDoc.ts:55

Unsubscribe from changes to this document

Parameters:

Name Type Description
callback Subscriber‹E› The callback to unsubscribe

Returns: void