Skip to content

Commit

Permalink
Merge pull request #95 from appwrite/dev
Browse files Browse the repository at this point in the history
Update attributes
  • Loading branch information
abnegate authored Sep 10, 2024
2 parents 7145816 + 68639f9 commit 7a2418c
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 23 deletions.
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 result = 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 result = 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 result = 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 result = 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 result = 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 result = 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 result = 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 result = await databases.updateRelationshipAttribute(
'<DATABASE_ID>', // databaseId
'<COLLECTION_ID>', // collectionId
'', // key
sdk.RelationMutate.Cascade // onDelete (optional)
sdk.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 result = 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 result = await databases.updateUrlAttribute(
'<COLLECTION_ID>', // collectionId
'', // key
false, // required
'https://example.com' // default
'https://example.com', // default
'' // newKey (optional)
);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "node-appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
"version": "14.0.0",
"version": "14.1.0",
"license": "BSD-3-Clause",
"main": "dist/index.js",
"type": "commonjs",
Expand Down
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppwriteException extends Error {
}

function getUserAgent() {
let ua = 'AppwriteNodeJSSDK/14.0.0';
let ua = 'AppwriteNodeJSSDK/14.1.0';

// `process` is a global in Node.js, but not fully available in all runtimes.
const platform: string[] = [];
Expand Down Expand Up @@ -82,7 +82,7 @@ class Client {
'x-sdk-name': 'Node.js',
'x-sdk-platform': 'server',
'x-sdk-language': 'nodejs',
'x-sdk-version': '14.0.0',
'x-sdk-version': '14.1.0',
'user-agent' : getUserAgent(),
'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 @@ -487,10 +487,11 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {boolean} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeBoolean>}
*/
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 All @@ -514,6 +515,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -591,10 +595,11 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeDatetime>}
*/
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 All @@ -618,6 +623,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -697,10 +705,11 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeEmail>}
*/
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 All @@ -724,6 +733,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -811,10 +823,11 @@ export class Databases {
* @param {string[]} elements
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeEnum>}
*/
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 @@ -844,6 +857,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -933,10 +949,11 @@ export class Databases {
* @param {number} min
* @param {number} max
* @param {number} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeFloat>}
*/
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 @@ -972,6 +989,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -1061,10 +1081,11 @@ export class Databases {
* @param {number} min
* @param {number} max
* @param {number} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeInteger>}
*/
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 @@ -1100,6 +1121,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -1179,10 +1203,11 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeIp>}
*/
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 All @@ -1206,6 +1231,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -1359,10 +1387,12 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {number} size
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeString>}
*/
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 All @@ -1386,6 +1416,12 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof size !== 'undefined') {
payload['size'] = size;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -1465,10 +1501,11 @@ export class Databases {
* @param {string} key
* @param {boolean} required
* @param {string} xdefault
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeUrl>}
*/
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 All @@ -1492,6 +1529,9 @@ export class Databases {
if (typeof xdefault !== 'undefined') {
payload['default'] = xdefault;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down Expand Up @@ -1587,10 +1627,11 @@ export class Databases {
* @param {string} collectionId
* @param {string} key
* @param {RelationMutate} onDelete
* @param {string} newKey
* @throws {AppwriteException}
* @returns {Promise<Models.AttributeRelationship>}
*/
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 @@ -1605,6 +1646,9 @@ export class Databases {
if (typeof onDelete !== 'undefined') {
payload['onDelete'] = onDelete;
}
if (typeof newKey !== 'undefined') {
payload['newKey'] = newKey;
}
const uri = new URL(this.client.config.endpoint + apiPath);

const apiHeaders: { [header: string]: string } = {
Expand Down

0 comments on commit 7a2418c

Please sign in to comment.