Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update attributes #23

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/examples/databases/update-boolean-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const response = await databases.updateBooleanAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
false // default
false, // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-datetime-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const response = await databases.updateDatetimeAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'' // default
'', // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-email-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const response = await databases.updateEmailAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'email@example.com' // default
'email@example.com', // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-enum-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const response = await databases.updateEnumAttribute(
'', // key
[], // elements
false, // required
'<DEFAULT>' // default
'<DEFAULT>', // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-float-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ const response = await databases.updateFloatAttribute(
false, // required
null, // min
null, // max
null // default
null, // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-integer-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ const response = await databases.updateIntegerAttribute(
false, // required
null, // min
null, // max
null // default
null, // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-ip-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const response = await databases.updateIpAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'' // default
'', // default
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-relationship-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ const response = await databases.updateRelationshipAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
RelationMutate.Cascade // onDelete (optional)
RelationMutate.Cascade, // onDelete (optional)
'' // newKey (optional)
);
4 changes: 3 additions & 1 deletion docs/examples/databases/update-string-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ const response = await databases.updateStringAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'<DEFAULT>' // default
'<DEFAULT>', // default
null, // size (optional)
'' // newKey (optional)
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-url-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ const response = await databases.updateUrlAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'https://example.com' // default
'https://example.com', // default
'' // newKey (optional)
);
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export class Client {
endpoint: string = 'https://cloud.appwrite.io/v1';
headers: Payload = {
'content-type': '',
'user-agent' : `AppwriteDenoSDK/12.0.0 (${Deno.build.os}; ${Deno.build.arch})`,
'user-agent' : `AppwriteDenoSDK/12.1.0 (${Deno.build.os}; ${Deno.build.arch})`,
'x-sdk-name': 'Deno',
'x-sdk-platform': 'server',
'x-sdk-language': 'deno',
'x-sdk-version': '12.0.0',
'x-sdk-version': '12.1.0',
'X-Appwrite-Response-Format':'1.6.0',
};

Expand Down
64 changes: 54 additions & 10 deletions src/services/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,11 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {boolean} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean): Promise<Models.AttributeBoolean> {
async updateBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.AttributeBoolean> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -547,6 +548,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -624,10 +628,11 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string): Promise<Models.AttributeDatetime> {
async updateDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeDatetime> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -657,6 +662,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -736,10 +744,11 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string): Promise<Models.AttributeEmail> {
async updateEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEmail> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -769,6 +778,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -858,10 +870,11 @@ export class Databases extends Service {
* @param {string[]} elements
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string): Promise<Models.AttributeEnum> {
async updateEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEnum> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -898,6 +911,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -988,10 +1004,11 @@ export class Databases extends Service {
* @param {number} min
* @param {number} max
* @param {number} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min: number, max: number, xdefault?: number): Promise<Models.AttributeFloat> {
async updateFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min: number, max: number, xdefault?: number, newKey?: string): Promise<Models.AttributeFloat> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -1035,6 +1052,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -1125,10 +1145,11 @@ export class Databases extends Service {
* @param {number} min
* @param {number} max
* @param {number} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min: number, max: number, xdefault?: number): Promise<Models.AttributeInteger> {
async updateIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min: number, max: number, xdefault?: number, newKey?: string): Promise<Models.AttributeInteger> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -1172,6 +1193,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -1251,10 +1275,11 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string): Promise<Models.AttributeIp> {
async updateIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeIp> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -1284,6 +1309,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -1441,10 +1469,12 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {number} size
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string): Promise<Models.AttributeString> {
async updateStringAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeString> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -1474,6 +1504,12 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof size !== 'undefined') {
payload['size'] = size;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -1553,10 +1589,11 @@ export class Databases extends Service {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string): Promise<Models.AttributeUrl> {
async updateUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeUrl> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand Down Expand Up @@ -1586,6 +1623,9 @@ export class Databases extends Service {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down Expand Up @@ -1681,10 +1721,11 @@ export class Databases extends Service {
* @param {string} collectionId
* @param {string} key
* @param {RelationMutate} onDelete
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise}
*/
async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate): Promise<Models.AttributeRelationship> {
async updateRelationshipAttribute(databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship> {
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
}
Expand All @@ -1703,6 +1744,9 @@ export class Databases extends Service {
if (typeof onDelete !== 'undefined') {
payload['onDelete'] = onDelete;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
return await this.client.call(
'patch',
apiPath,
Expand Down