Craft Document DB
const { docDb } = MODULES;Table of Contents
Section titled “Table of Contents”Schemas
Section titled “Schemas”DocDbSchemaField
Section titled “DocDbSchemaField”Type: Object
Properties
Section titled “Properties”type("string"|"number"|"boolean"|"date"|"array") フィールドの型items("string"|"number"|"boolean"|"date")? 配列型の場合の要素型primaryKeyboolean? 主キーにする場合はtrue
DocDbFindParam
Section titled “DocDbFindParam”Type: Object
Properties
Section titled “Properties”collectionNamestring 検索対象のコレクション名whereobject? 検索条件。{ field: value }または{ field: { eq|gt|gte|lt|lte|has|hasAny: value } }を指定orderByobject? ソート条件。{ field: 'asc' | 'desc' }を指定takenumber? 取得件数。デフォルトは10cursorstring? 次ページ取得用カーソル
DocDbFindResult
Section titled “DocDbFindResult”Type: Object
Properties
Section titled “Properties”dataArray<object> 条件に一致したドキュメントの配列nextCursor(string | null) 次ページ取得用カーソル。続きがない場合はnullhasMoreboolean 次ページが存在するかどうか
Methods
Section titled “Methods”getSchema
Section titled “getSchema”Craft DocumentDBのコレクションのスキーマを取得する
Parameters
Section titled “Parameters”Returns Promise<{schema: Object<string, DocDbSchemaField>}> コレクションのスキーマ定義
createCollection
Section titled “createCollection”Craft DocumentDBにスキーマ付きのコレクションを作成する
Parameters
Section titled “Parameters”-
paramobjectparam.collectionNamestring 作成するコレクション名param.schemaObject<string, DocDbSchemaField> コレクションのスキーマ定義
Returns Promise<object> empty object
insert
Section titled “insert”Craft DocumentDBにドキュメントを登録する
Parameters
Section titled “Parameters”Returns Promise<{data: object}> 登録したドキュメント
Craft DocumentDBからドキュメントを検索する
Parameters
Section titled “Parameters”-
paramDocDbFindParamparam.collectionNameparam.whereparam.orderByparam.take(optional, default10)param.cursor
Returns Promise<DocDbFindResult> 検索結果
update
Section titled “update”Craft DocumentDBのドキュメントを更新する
Parameters
Section titled “Parameters”-
paramobject
Returns Promise<{data: object}> 更新後のドキュメント
delete
Section titled “delete”Craft DocumentDBからドキュメントを削除する