本文整理汇总了TypeScript中protobufjs/minimal.util.isset方法的典型用法代码示例。如果您正苦于以下问题:TypeScript util.isset方法的具体用法?TypeScript util.isset怎么用?TypeScript util.isset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protobufjs/minimal.util
的用法示例。
在下文中一共展示了util.isset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getEventDescription
export function getEventDescription(e: Event$Properties): string {
const info: {
DatabaseName: string,
DroppedTables: string[],
IndexName: string,
MutationID: string,
TableName: string,
User: string,
ViewName: string,
SettingName: string,
Value: string,
} = protobuf.util.isset(e, "info") ? JSON.parse(e.info) : {};
const targetId: number = e.target_id ? e.target_id.toNumber() : null;
switch (e.event_type) {
case eventTypes.CREATE_DATABASE:
return `Database Created: User ${info.User} created database ${info.DatabaseName}`;
case eventTypes.DROP_DATABASE:
info.DroppedTables = info.DroppedTables || [];
let tableDropText: string = `${info.DroppedTables.length} tables were dropped: ${info.DroppedTables.join(", ")}`;
if (info.DroppedTables.length === 0) {
tableDropText = "No tables were dropped.";
} else if (info.DroppedTables.length === 1) {
tableDropText = `1 table was dropped: ${info.DroppedTables[0]}`;
}
return `Database Dropped: User ${info.User} dropped database ${info.DatabaseName}.${tableDropText}`;
case eventTypes.CREATE_TABLE:
return `Table Created: User ${info.User} created table ${info.TableName}`;
case eventTypes.DROP_TABLE:
return `Table Dropped: User ${info.User} dropped table ${info.TableName}`;
case eventTypes.ALTER_TABLE:
return `Schema Change: User ${info.User} began a schema change to alter table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.CREATE_INDEX:
return `Schema Change: User ${info.User} began a schema change to create an index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.DROP_INDEX:
return `Schema Change: User ${info.User} began a schema change to drop index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.CREATE_VIEW:
return `View Created: User ${info.User} created view ${info.ViewName}`;
case eventTypes.DROP_VIEW:
return `View Dropped: User ${info.User} dropped view ${info.ViewName}`;
case eventTypes.REVERSE_SCHEMA_CHANGE:
return `Schema Change Reversed: Schema change with ID ${info.MutationID} was reversed.`;
case eventTypes.FINISH_SCHEMA_CHANGE:
return `Schema Change Completed: Schema change with ID ${info.MutationID} was completed.`;
case eventTypes.FINISH_SCHEMA_CHANGE_ROLLBACK:
return `Schema Change Rollback Completed: Rollback of schema change with ID ${info.MutationID} was completed.`;
case eventTypes.NODE_JOIN:
return `Node Joined: Node ${targetId} joined the cluster`;
case eventTypes.NODE_DECOMMISSIONED:
return `Node Decommissioned: Node ${targetId} was decommissioned`;
case eventTypes.NODE_RECOMMISSIONED:
return `Node Recommissioned: Node ${targetId} was recommissioned`;
case eventTypes.NODE_RESTART:
return `Node Rejoined: Node ${targetId} rejoined the cluster`;
case eventTypes.SET_CLUSTER_SETTING:
return `Cluster Setting Changed: User ${info.User} set ${info.SettingName} to ${info.Value}`;
default:
return `Unknown Event Type: ${e.event_type}, content: ${JSON.stringify(info, null, 2)}`;
}
}
示例2: getEventDescription
export function getEventDescription(e: Event$Properties): string {
const info: EventInfo = protobuf.util.isset(e, "info") ? JSON.parse(e.info) : {};
const targetId: number = e.target_id ? e.target_id.toNumber() : null;
switch (e.event_type) {
case eventTypes.CREATE_DATABASE:
return `Database Created: User ${info.User} created database ${info.DatabaseName}`;
case eventTypes.DROP_DATABASE:
const tableDropText = getDroppedObjectsText(info);
return `Database Dropped: User ${info.User} dropped database ${info.DatabaseName}. ${tableDropText}`;
case eventTypes.CREATE_TABLE:
return `Table Created: User ${info.User} created table ${info.TableName}`;
case eventTypes.DROP_TABLE:
return `Table Dropped: User ${info.User} dropped table ${info.TableName}`;
case eventTypes.TRUNCATE_TABLE:
return `Table Truncated: User ${info.User} truncated table ${info.TableName}`;
case eventTypes.ALTER_TABLE:
return `Schema Change: User ${info.User} began a schema change to alter table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.CREATE_INDEX:
return `Schema Change: User ${info.User} began a schema change to create an index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.DROP_INDEX:
return `Schema Change: User ${info.User} began a schema change to drop index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.ALTER_INDEX:
return `Schema Change: User ${info.User} began a schema change to alter index ${info.IndexName} on table ${info.TableName} with ID ${info.MutationID}`;
case eventTypes.CREATE_VIEW:
return `View Created: User ${info.User} created view ${info.ViewName}`;
case eventTypes.DROP_VIEW:
return `View Dropped: User ${info.User} dropped view ${info.ViewName}`;
case eventTypes.CREATE_SEQUENCE:
return `Sequence Created: User ${info.User} created sequence ${info.SequenceName}`;
case eventTypes.ALTER_SEQUENCE:
return `Sequence Altered: User ${info.User} altered sequence ${info.SequenceName}`;
case eventTypes.DROP_SEQUENCE:
return `Sequence Dropped: User ${info.User} dropped sequence ${info.SequenceName}`;
case eventTypes.REVERSE_SCHEMA_CHANGE:
return `Schema Change Reversed: Schema change with ID ${info.MutationID} was reversed.`;
case eventTypes.FINISH_SCHEMA_CHANGE:
return `Schema Change Completed: Schema change with ID ${info.MutationID} was completed.`;
case eventTypes.FINISH_SCHEMA_CHANGE_ROLLBACK:
return `Schema Change Rollback Completed: Rollback of schema change with ID ${info.MutationID} was completed.`;
case eventTypes.NODE_JOIN:
return `Node Joined: Node ${targetId} joined the cluster`;
case eventTypes.NODE_DECOMMISSIONED:
return `Node Decommissioned: Node ${targetId} was decommissioned`;
case eventTypes.NODE_RECOMMISSIONED:
return `Node Recommissioned: Node ${targetId} was recommissioned`;
case eventTypes.NODE_RESTART:
return `Node Rejoined: Node ${targetId} rejoined the cluster`;
case eventTypes.SET_CLUSTER_SETTING:
if (info.Value && info.Value.length > 0) {
return `Cluster Setting Changed: User ${info.User} set ${info.SettingName} to ${info.Value}`;
}
return `Cluster Setting Changed: User ${info.User} changed ${info.SettingName}`;
case eventTypes.SET_ZONE_CONFIG:
return `Zone Config Changed: User ${info.User} set the zone config for ${info.Target} to ${info.Config}`;
case eventTypes.REMOVE_ZONE_CONFIG:
return `Zone Config Removed: User ${info.User} removed the zone config for ${info.Target}`;
default:
return `Unknown Event Type: ${e.event_type}, content: ${JSON.stringify(info, null, 2)}`;
}
}