Class: Stack
Defined in: server/src/utils/stack/index.ts:66
Extends
Stack
Properties
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|---|---|---|---|---|---|---|
addDesignDocumentPKs | abstract | (className, pKs, temp?) => Promise<string> | undefined | - | Stack.addDesignDocumentPKs | shared/src/utils/stack/index.ts:230 |
addDomain | abstract | (domainObj) => Promise<DomainModel> | undefined | - | Stack.addDomain | shared/src/utils/stack/index.ts:63 |
appVersion | public | string | "0.0.1" | - | Stack.appVersion | shared/src/utils/stack/index.ts:28 |
authSession? | public | AuthSessionProof | undefined | - | Stack.authSession | shared/src/utils/stack/index.ts:47 |
cache | public | object | {} | - | Stack.cache | shared/src/utils/stack/index.ts:31 |
connection | public | string | undefined | - | Stack.connection | shared/src/utils/stack/index.ts:25 |
createDocs | abstract | (docs, type, classObj) => Promise<Document[]> | undefined | - | Stack.createDocs | shared/src/utils/stack/index.ts:202 |
createRelationDoc | abstract | (docId, relationName, domainObj, params) => Promise<RelationDocument> | undefined | - | Stack.createRelationDoc | shared/src/utils/stack/index.ts:204 |
createRelationDocs | abstract | (docs, relationName, domainObj) => Promise<RelationDocument[]> | undefined | - | Stack.createRelationDocs | shared/src/utils/stack/index.ts:211 |
db | public | Database<{ }> | undefined | - | Stack.db | shared/src/utils/stack/index.ts:21 |
dump | abstract | () => Promise<AllDocsResponse<{ }>> | undefined | - | Stack.dump | shared/src/utils/stack/index.ts:49 |
getDomain | abstract | (domainName, fresh?) => Promise<Domain> | undefined | - | Stack.getDomain | shared/src/utils/stack/index.ts:59 |
getDomainModel | abstract | (domainName) => Promise<DomainModel> | undefined | - | Stack.getDomainModel | shared/src/utils/stack/index.ts:226 |
jobEngine? | public | unknown | undefined | - | Stack.jobEngine | shared/src/utils/stack/index.ts:46 |
lastDocId | public | number | undefined | - | Stack.lastDocId | shared/src/utils/stack/index.ts:23 |
listeners | public | ChangesSubscription[] | [] | Every live changes subscription this stack has handed out. Held so removeAllListeners can release them on close. Entries are removed by releaseListener, so a long-lived stack that repeatedly subscribes and unsubscribes does not grow this array. | Stack.listeners | shared/src/utils/stack/index.ts:43 |
modelWorker | public | Worker | null | - | Stack.modelWorker | shared/src/utils/stack/index.ts:45 |
name | abstract | string | undefined | - | Stack.name | shared/src/utils/stack/index.ts:27 |
options? | public | StackOptions | undefined | - | Stack.options | shared/src/utils/stack/index.ts:26 |
patchCount | public | number | undefined | - | Stack.patchCount | shared/src/utils/stack/index.ts:34 |
query | abstract | (sql, ...params) => Promise< | { ast: (SelectAST | UnionAST)[]; rows: any[]; } | { ast: null; rows: never[]; }> | undefined | - | Stack.query | shared/src/utils/stack/index.ts:232 |
schemaVersion | abstract | string | undefined | - | Stack.schemaVersion | shared/src/utils/stack/index.ts:29 |
Methods
addClass()
addClass(classObj): Promise<ClassModel>;
Defined in: server/src/utils/stack/index.ts:740
Parameters
| Parameter | Type |
|---|---|
classObj | Class |
Returns
Promise<ClassModel>
Overrides
Stack.addClass
addClassLock()
addClassLock(className): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:436
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Promise<boolean>
Overrides
Stack.addClassLock
checkSystem()
checkSystem(): Promise<void>;
Defined in: server/src/utils/stack/index.ts:242
Returns
Promise<void>
clearClassLock()
clearClassLock(className): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:451
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Promise<boolean>
Overrides
Stack.clearClassLock
close()
close(): void;
Defined in: server/src/utils/stack/index.ts:488
Returns
void
Overrides
Stack.close
createDoc()
createDoc(
docId,
type,
classObj,
params): Promise<Document>;
Defined in: server/src/utils/stack/index.ts:991
Parameters
| Parameter | Type |
|---|---|
docId | string |
type | string |
classObj | Class |
params | { } |
Returns
Promise<Document>
Overrides
Stack.createDoc
deleteDocument()
deleteDocument(_id): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:1082
Sets the active param of a document to false
Parameters
| Parameter | Type | Description |
|---|---|---|
_id | string |
Returns
Promise<boolean>
Promise
Async
Overrides
Stack.deleteDocument
destroyDb()
destroyDb(): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:709
Returns
Promise<boolean>
findDocument()
findDocument(
selector,
fields,
skip,
limit): Promise<Document>;
Defined in: server/src/utils/stack/index.ts:605
Parameters
| Parameter | Type | Default value |
|---|---|---|
selector | any | undefined |
fields | any | undefined |
skip | any | undefined |
limit | any | undefined |
Returns
Promise<Document>
findDocuments()
findDocuments(
selector,
fields?,
skip?,
limit?): Promise<{
[key: string]: any;
docs: Document[];
}>;
Defined in: server/src/utils/stack/index.ts:564
Parameters
| Parameter | Type |
|---|---|
selector | { [key: string]: any; } |
fields? | string[] |
skip? | number |
limit? | number |
Returns
Promise<{
[key: string]: any;
docs: Document[];
}>
Overrides
Stack.findDocuments
getAllClasses()
getAllClasses(): Promise<Class[]>;
Defined in: server/src/utils/stack/index.ts:643
Returns
Promise<Class[]>
getAllClassModels()
getAllClassModels(): Promise<ClassModel[]>;
Defined in: server/src/utils/stack/index.ts:658
Returns
Promise<ClassModel[]>
getClass()
getClass(className): Promise<Class>;
Defined in: server/src/utils/stack/index.ts:493
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Promise<Class>
Overrides
Stack.getClass
getClassModel()
getClassModel(className): Promise<ClassModel>;
Defined in: server/src/utils/stack/index.ts:611
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Promise<ClassModel>
Overrides
Stack.getClassModel
getClassModels()
getClassModels(classNames): Promise<ClassModel[]>;
Defined in: server/src/utils/stack/index.ts:669
Parameters
| Parameter | Type |
|---|---|
classNames | string[] |
Returns
Promise<ClassModel[]>
getDb()
getDb(): Database<{
}>;
Defined in: server/src/utils/stack/index.ts:117
Returns
Database<{
}>
getDbInfo()
getDbInfo(): Promise<DatabaseInfo>;
Defined in: server/src/utils/stack/index.ts:121
Returns
Promise<DatabaseInfo>
getDbName()
getDbName(): string;
Defined in: server/src/utils/stack/index.ts:125
Returns
string
getDocRevision()
getDocRevision(docId): Promise<string>;
Defined in: server/src/utils/stack/index.ts:551
Parameters
| Parameter | Type |
|---|---|
docId | string |
Returns
Promise<string>
getDocument()
getDocument(docId): Promise<ExistingDocument<{
}>>;
Defined in: server/src/utils/stack/index.ts:536
Parameters
| Parameter | Type |
|---|---|
docId | string |
Returns
Promise<ExistingDocument<{
}>>
getLastDocId()
getLastDocId(): Promise<number>;
Defined in: server/src/utils/stack/index.ts:137
Returns
Promise<number>
getSystem()
getSystem(): Promise<SystemDoc>;
Defined in: server/src/utils/stack/index.ts:152
Returns
Promise<SystemDoc>
incrementLastDocId()
incrementLastDocId(): Promise<number>;
Defined in: server/src/utils/stack/index.ts:680
Returns
Promise<number>
initdb()
initdb(): Promise<ServerStack>;
Defined in: server/src/utils/stack/index.ts:481
Returns
Promise<ServerStack>
initIndex()
initIndex(): Promise<void>;
Defined in: server/src/utils/stack/index.ts:507
Returns
Promise<void>
onClassDoc()
onClassDoc(className): Changes<{
}>;
Defined in: server/src/utils/stack/index.ts:465
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Changes<{
}>
Overrides
Stack.onClassDoc
onClassLock()
onClassLock(className): Changes<{
}>;
Defined in: server/src/utils/stack/index.ts:423
Parameters
| Parameter | Type |
|---|---|
className | string |
Returns
Changes<{
}>
Overrides
Stack.onClassLock
onClassModelChanges()
onClassModelChanges(): Changes<{
}>;
Defined in: server/src/utils/stack/index.ts:357
Listener that fires when a document that refers to a class is edited or created, marks its execution while handling the propagation of schema modifications to children documents: by dispatching a webworker message containing the
Returns
Changes<{
}>
void
Var
className and the previous revision id. In the main case, the worker sends a message with the result of its task.
Fires
class-model-propagation-complete
Fires
class-model-propagation-pending
onClassModelPropagationComplete()
onClassModelPropagationComplete(event): void;
Defined in: server/src/utils/stack/index.ts:338
Parameters
| Parameter | Type | Description |
|---|---|---|
event | CustomEvent<ClassModelPropagationComplete> |
Returns
void
Description
When a class model propagation comes to completion remove the corresponding ~lock from the database
onClassModelPropagationStart()
onClassModelPropagationStart(event): void;
Defined in: server/src/utils/stack/index.ts:323
Parameters
| Parameter | Type | Description |
|---|---|---|
event | CustomEvent<ClassModelPropagationStart> |
Returns
void
Description
When a class model propagation starts write the ~lock document to the database. It prevents any further modifications on the class data model
Overrides
Stack.onClassModelPropagationStart
prepareChangeDocument()
prepareChangeDocument(doc, classObj?): Promise<Document>;
Defined in: shared/src/utils/stack/index.ts:100
Prepares a document from the changes feed for delivery to a listener.
The base implementation passes it through, which is correct for a stack that does not encrypt. A stack that does overrides this: the feed bypasses the plugin that decrypts reads, so a stored encrypted attribute would otherwise reach a consumer as its raw payload. See ADR-0020.
Parameters
| Parameter | Type | Description |
|---|---|---|
doc | Document | The document from change.doc. |
classObj? | Class | The class, when the caller has one. |
Returns
Promise<Document>
Inherited from
Stack.prepareChangeDocument
prepareDoc()
prepareDoc(
_id,
type,
params): object;
Defined in: server/src/utils/stack/index.ts:981
Parameters
| Parameter | Type |
|---|---|
_id | string |
type | string |
params | { [key: string]: string | number | boolean; } |
Returns
object
releaseListener()
releaseListener(listener?): void;
Defined in: shared/src/utils/stack/index.ts:186
Cancels a subscription and forgets it.
The counterpart to subscribeClassDocs: a caller that is done watching must call this rather than dropping the handle, because the subscription keeps the underlying feed - and everything the handler closes over - alive on its own. Safe to call with a handle that is already cancelled, or with nothing at all.
Parameters
| Parameter | Type | Description |
|---|---|---|
listener? | ChangesSubscription | The handle to release. |
Returns
void
Inherited from
Stack.releaseListener
removeAllListeners()
removeAllListeners(): void;
Defined in: server/src/utils/stack/index.ts:312
Returns
void
Description
Clears all listeners from the Stack
Overrides
Stack.removeAllListeners
reset()
reset(): Promise<ServerStack>;
Defined in: server/src/utils/stack/index.ts:698
Returns
Promise<ServerStack>
setListeners()
setListeners(): void;
Defined in: server/src/utils/stack/index.ts:280
Returns
void
Overrides
Stack.setListeners
subscribeClassDocs()
subscribeClassDocs(
className,
target,
classObj?): ChangesSubscription;
Defined in: shared/src/utils/stack/index.ts:117
Subscribes an event target to a class's document changes.
Prefer this over wiring onClassDoc directly. It routes every change through
prepareChangeDocument, so a subclass that encrypts cannot forget to decrypt
on this path, and it serialises the handlers: preparing a document is asynchronous,
so two rapid changes to one document could otherwise be dispatched in whichever
order their preparation happened to finish. The change's seq still rides along
for consumers that want to discard a stale update independently.
Parameters
| Parameter | Type | Description |
|---|---|---|
className | string | The class whose documents to watch. |
target | EventTarget | Receives the doc events. |
classObj? | Class | The class, when the caller has one. |
Returns
ChangesSubscription
The underlying changes listener.
Inherited from
Stack.subscribeClassDocs
subscribeDomainDocs()
subscribeDomainDocs(domainName, target): ChangesSubscription;
Defined in: shared/src/utils/stack/index.ts:133
Subscribes an event target to a domain's relation documents.
The Domain counterpart to subscribeClassDocs, and it needs to be a separate
call rather than the same one: a relation document is named by ~domain and has no
~class, so subscribing it as if it were a class matches nothing and the target
simply never hears anything.
Parameters
| Parameter | Type | Description |
|---|---|---|
domainName | string | The domain whose relations to watch. |
target | EventTarget | Receives the doc events. |
Returns
ChangesSubscription
The underlying subscription.
Inherited from
Stack.subscribeDomainDocs
updateClass()
updateClass(classObj): Promise<Document>;
Defined in: server/src/utils/stack/index.ts:765
Parameters
| Parameter | Type |
|---|---|
classObj | Class |
Returns
Promise<Document>
Overrides
Stack.updateClass
validateObject()
validateObject(
obj,
type,
schema): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:784
Parameters
| Parameter | Type |
|---|---|
obj | any |
type | string |
schema | { [name: string]: AttributeModel; } |
Returns
Promise<boolean>
validateObjectByType()
validateObjectByType(
obj,
type,
schema?): Promise<boolean>;
Defined in: server/src/utils/stack/index.ts:954
Parameters
| Parameter | Type |
|---|---|
obj | any |
type | string |
schema? | { [name: string]: AttributeModel; } |
Returns
Promise<boolean>
clear()
static clear(conn): Promise<unknown>;
Defined in: server/src/utils/stack/index.ts:725
Parameters
| Parameter | Type |
|---|---|
conn | string |
Returns
Promise<unknown>
create()
static create(conn, options?): Promise<ServerStack>;
Defined in: server/src/utils/stack/index.ts:130
Parameters
| Parameter | Type |
|---|---|
conn | string |
options? | StoreOptions |
Returns
Promise<ServerStack>