本文整理汇总了TypeScript中promise-mysql.IPool.query方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IPool.query方法的具体用法?TypeScript IPool.query怎么用?TypeScript IPool.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类promise-mysql.IPool
的用法示例。
在下文中一共展示了IPool.query方法的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: getByID
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: getByName
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: getByAddress
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;
});
}