Aracılığıyla paylaş


Users class

Tüm kullanıcıları oluşturmak, eklemek, sorgulamak ve okumak için kullanılır.

Belirli bir Kullanıcıyı kimliğe göre okumak, değiştirmek veya silmek için bkz. Kullanıcı.

Özellikler

database

Yöntemler

create(UserDefinition, RequestOptions)

UserDefinition belirtilenile bir veritabanı kullanıcısı oluşturun.

Örnek

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>" });
query(SqlQuerySpec, FeedOptions)

Tüm kullanıcıları sorgula.

query<T>(SqlQuerySpec, FeedOptions)

Tüm kullanıcıları sorgula.

Örnek

Kullanıcıyı id ile sorgulayın.

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();
readAll(FeedOptions)

Tüm kullanıcıları oku.-

Örnek

Tüm kullanıcıları diziye okuma.

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();
upsert(UserDefinition, RequestOptions)

Belirtilen UserDefinitionolan bir veritabanı kullanıcısı ekler.

Örnek

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>" });

Özellik Ayrıntıları

database

database: Database

Özellik Değeri

Yöntem Ayrıntıları

create(UserDefinition, RequestOptions)

UserDefinition belirtilenile bir veritabanı kullanıcısı oluşturun.

Örnek

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>

Parametreler

body
UserDefinition

Belirtilen UserDefinition.

options
RequestOptions

Döndürülenler

Promise<UserResponse>

query(SqlQuerySpec, FeedOptions)

Tüm kullanıcıları sorgula.

function query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator<any>

Parametreler

query
SqlQuerySpec

İşlem için sorgu yapılandırması. Sorgu yapılandırma hakkında daha fazla bilgi için bkz. SqlQuerySpec.

options
FeedOptions

Döndürülenler

query<T>(SqlQuerySpec, FeedOptions)

Tüm kullanıcıları sorgula.

Örnek

Kullanıcıyı id ile sorgulayın.

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>

Parametreler

query
SqlQuerySpec

İşlem için sorgu yapılandırması. Sorgu yapılandırma hakkında daha fazla bilgi için bkz. SqlQuerySpec.

options
FeedOptions

Döndürülenler

readAll(FeedOptions)

Tüm kullanıcıları oku.-

Örnek

Tüm kullanıcıları diziye okuma.

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>

Parametreler

options
FeedOptions

Döndürülenler

upsert(UserDefinition, RequestOptions)

Belirtilen UserDefinitionolan bir veritabanı kullanıcısı ekler.

Örnek

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>

Parametreler

body
UserDefinition

Belirtilen UserDefinition.

options
RequestOptions

Döndürülenler

Promise<UserResponse>