本文整理匯總了TypeScript中promise-mysql.IPool類的典型用法代碼示例。如果您正苦於以下問題:TypeScript IPool類的具體用法?TypeScript IPool怎麽用?TypeScript IPool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IPool類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setHost
setHost(region: IRegion, host: IHost, port: number): Promise<IRegion> {
let address: string = host ? host.address : '';
return this.db.query('UPDATE regions SET httpPort=?, slaveAddress=? WHERE uuid=?', [port, address, region.uuid]).then(() => {
region.node = address;
return region;
});
}
示例2: setXY
setXY(region: IRegion, x: number, y: number): Promise<IRegion> {
return this.db.query('UPDATE regions SET locX=?, locY=? WHERE uuid=?', [x, y, region.uuid]).then(() => {
region.x = x;
region.y = y;
return region;
});
}
示例3: Error
getByID(id: number): Promise<IJob> {
return this.db.query('SELECT * FROM jobs WHERE id=?', id).then((rows: job_row[]) => {
if (rows.length !== 1)
throw new Error('Job ' + id + ' does not exist');
return rows[0];
});
}
示例4: Error
getByName(name: string): Promise<IPendingUser> {
return this.db.query('SELECT * FROM users WHERE name=?', name).then((rows: pending_user_row[]) => {
if (rows.length !== 1)
throw new Error('Pending User ' + name + ' does not exist');
return rows[0];
});
}
示例5:
return Promise.all(rows.map((r: inventoryItem) => {
let v: inventoryItem = {
assetID: r.assetType == 24 ? uuidMap[r.assetID] : r.assetID, // type 24 is a link
assetType: r.assetType,
inventoryName: r.inventoryName,
inventoryDescription: r.inventoryDescription,
inventoryNextPermissions: r.inventoryNextPermissions,
inventoryCurrentPermissions: r.inventoryCurrentPermissions,
invType: r.invType,
creatorID: r.creatorID,
inventoryBasePermissions: r.inventoryBasePermissions,
inventoryEveryOnePermissions: r.inventoryEveryOnePermissions,
salePrice: r.salePrice,
saleType: r.saleType,
creationDate: r.creationDate,
groupID: r.groupID,
groupOwned: r.groupOwned,
flags: r.flags,
inventoryID: invMap[r.inventoryID],
avatarID: target.UUID,
parentFolderID: uuidMap[r.parentFolderID],
inventoryGroupPermissions: r.inventoryGroupPermissions
}
return db.query('INSERT INTO inventoryitems SET ?', v);
}))
示例6: Error
getByAddress(address: string): Promise<IHost> {
return this.db.query('SELECT * FROM hosts WHERE address=?', [address]).then((rows: hosts_row[]) => {
if (rows.length == 0)
throw new Error('Host ' + address + ' does not exist');
return rows[0];
});
}
示例7: create
create(address: string): Promise<IHost> {
let host: hosts_row = {
address: address,
port: 0,
name: '',
slots: 0
}
return this.db.query('INSERT INTO hosts SET ?', host).then((result) => {
host.id = result.insertId;
return host;
});
}
示例8: create
create(type: string, user: IUser, data: string): Promise<IJob> {
let job: job_row = {
timestamp: new Date(),
type: type,
user: user.UUID,
data: data
}
return this.db.query('INSERT INTO jobs SET ?', job).then((result) => {
job.id = result.insertId;
return job;
});
}