Users class
すべてのユーザーの作成、アップサート、クエリ、読み取りに使用されます。
特定のユーザー ID による読み取り、置換、または削除を行うユーザー を参照してください。
プロパティ
database |
メソッド
create(User |
UserDefinition を指定データベース ユーザーを作成します。 例
|
query(Sql |
すべてのユーザーにクエリを実行します。 |
query<T>(Sql |
すべてのユーザーにクエリを実行します。 例 ID を使用してユーザーをクエリします。
|
read |
すべてのユーザーを読み取る。- 例 すべてのユーザーを配列に読み取る。
|
upsert(User |
UserDefinition を指定データベース ユーザーをアップサートします。 例
|
プロパティの詳細
database
メソッドの詳細
create(UserDefinition, RequestOptions)
UserDefinition を指定データベース ユーザーを作成します。
例
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
await database.users.create({ id: "<user-id>" });
function create(body: UserDefinition, options?: RequestOptions): Promise<UserResponse>
パラメーター
- body
- UserDefinition
指定した UserDefinition。
- options
- RequestOptions
戻り値
Promise<UserResponse>
query(SqlQuerySpec, FeedOptions)
すべてのユーザーにクエリを実行します。
function query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>
パラメーター
- query
- SqlQuerySpec
操作のクエリ構成。 クエリ 構成する方法の詳細については、SqlQuerySpec を参照してください。
- options
- FeedOptions
戻り値
QueryIterator<any>
query<T>(SqlQuerySpec, FeedOptions)
すべてのユーザーにクエリを実行します。
例
ID を使用してユーザーをクエリします。
import { CosmosClient, SqlQuerySpec } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const querySpec: SqlQuerySpec = {
query: `SELECT * FROM root r WHERE r.id = @user`,
parameters: [{ name: "@user", value: "<user-id>" }],
};
const { resources: permisssion } = await database.users.query(querySpec).fetchAll();
function query<T>(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<T>
パラメーター
- query
- SqlQuerySpec
操作のクエリ構成。 クエリ 構成する方法の詳細については、SqlQuerySpec を参照してください。
- options
- FeedOptions
戻り値
readAll(FeedOptions)
すべてのユーザーを読み取る。-
例
すべてのユーザーを配列に読み取る。
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { resources: usersList } = await database.users.readAll().fetchAll();
function readAll(options?: FeedOptions): QueryIterator<UserDefinition & Resource>
パラメーター
- options
- FeedOptions
戻り値
upsert(UserDefinition, RequestOptions)
UserDefinition を指定データベース ユーザーをアップサートします。
例
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
await database.users.upsert({ id: "<user-id>" });
function upsert(body: UserDefinition, options?: RequestOptions): Promise<UserResponse>
パラメーター
- body
- UserDefinition
指定した UserDefinition。
- options
- RequestOptions
戻り値
Promise<UserResponse>