本文整理汇总了TypeScript中mysql.format函数的典型用法代码示例。如果您正苦于以下问题:TypeScript format函数的具体用法?TypeScript format怎么用?TypeScript format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: update
update(tagGroup: TagGroup, option?: MariaDBBase.QueryOption): Promise<void> {
if (!option) option = {commit: true};
let sql: string = mysql.format(
"DELETE FROM tag_group_member WHERE tagGroupId = ?;",
[tagGroup.id]
);
sql += mysql.format(
"UPDATE tag_group SET name = ? WHERE tagGroupId = ?;",
[tagGroup.name, tagGroup.id]
);
const self = this;
return this.getConnection(option.transaction)
.then(connection =>
self.tags_.saveAll(tagGroup.member, {transaction: connection})
.then(() => self.executeUpdate(sql, {transaction: connection}))
.then(() =>
self.executeUpdate(
self.memberInsertSql(tagGroup),
{transaction: connection, commit: option.commit}
)
)
.then(() => tagGroup.saved())
);
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:30,代码来源:TagGroupMariaDBContainer.ts
示例2: remove
remove(tagGroup: TagGroup, option?: MariaDBBase.QueryOption): Promise<void> {
let sql: string = mysql.format(
"DELETE FROM tag_group_member WHERE tagGroupId = ?;",
[tagGroup.id]
);
sql += mysql.format(
"DELETE FROM tag_group WHERE tagGroupId = ?;",
[tagGroup.id]
);
return this.executeUpdate(sql, option);
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:15,代码来源:TagGroupMariaDBContainer.ts
示例3: insert
insert(tagGroup: TagGroup, option?: MariaDBBase.QueryOption): Promise<void> {
if (!option) option = {commit: true};
let sql: string = mysql.format(
"INSERT INTO tag_group (name) VALUES (?);",
[tagGroup.name]
);
const self = this;
return this.getConnection(option.transaction)
.then(connection => self.query(sql, {transaction: connection})
.then(result => {
tagGroup.defineId(result["insertId"]);
return self.tags_.saveAll(tagGroup.member, {transaction: connection});
})
.then(() => self.executeUpdate(
self.memberInsertSql(tagGroup),
{transaction: connection, commit: option.commit}
))
.then(() => tagGroup.saved())
);
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:25,代码来源:TagGroupMariaDBContainer.ts
示例4: format
async query<T>(sql: string, inserts: any = []) {
const SQL = format(sql, inserts);
return new Promise<T[]>((resolve, reject) => {
this._connection.query(SQL, (err, results) => {
if (err) { reject(err); } else { resolve(results); }
});
});
}
开发者ID:chasidic,项目名称:mysql,代码行数:8,代码来源:MysqlConnection.ts
示例5: remove
remove(question: Question, option?: MariaDBBase.QueryOption): Promise<void> {
const sql: string = mysql.format(
"DELETE FROM question WHERE questionId = ?;",
[question.id]
);
return this.executeUpdate(sql, option);
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:10,代码来源:QuestionMariaDBContainer.ts
示例6: update
update(question: Question, option?: MariaDBBase.QueryOption): Promise<void> {
const sql: string = mysql.format(
"UPDATE question SET closed = ? WHERE questionId = ?;",
[question.isClosed, question.id]
);
return this.executeUpdate(sql, option)
.then(() => question.saved());
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:11,代码来源:QuestionMariaDBContainer.ts
示例7: insert
insert(log: RequestLog, option?: MariaDBBase.QueryOption): Promise<void> {
if (!option) option = {commit: true};
const sql1: string = mysql.format(
"INSERT INTO request_log(contextId, date, userMessage) VALUES(?, ?, ?);",
[
log.contextId,
log.date,
log.userMessage
]
);
const self = this;
let getConnection: Promise<mysql.IConnection>;
if (option.transaction) {
getConnection = Promise.resolve(option.transaction);
} else {
getConnection = this.getConnection();
}
return getConnection
.then(connection => {
option.transaction = connection;
return self.query(sql1, {transaction: option.transaction})
})
.then(result => {
const insertId: number = result["insertId"];
log.defineId(insertId);
let sql2: string = "";
for (const mmNum in log.meshinatorMessages) {
sql2 += mysql.format(
"INSERT INTO meshinator_message(logId, num, message) VALUES (?, ?, ?);",
[
insertId,
mmNum,
log.meshinatorMessages[mmNum]
]
);
}
if (sql2) {
return self.executeUpdate(sql2, option);
} else {
return Promise.resolve();
}
})
.then(() => log.saved());
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:51,代码来源:RequestLogMariaDBContainer.ts
示例8: addRecord
addRecord(record: TaggingRecord, option?: MariaDBBase.QueryOption): Promise<void> {
let sql: string = mysql.format(
"INSERT INTO tagging_record (itemId, tagId, questionId, value)"
+ "VALUES (?, ?, ?, ?);",
[
record.itemId,
record.tagId,
record.questionId,
record.value
]
);
sql += mysql.format(
"INSERT IGNORE INTO tagging (itemId, tagId, weight) VALUES (?, ?, ?);",
[
record.itemId,
record.tagId,
0
]
);
sql += mysql.format(
"UPDATE tagging SET weight = weight +(?) WHERE itemId = ? AND tagId = ?;",
[
record.value,
record.itemId,
record.tagId
]
);
return this.query(sql, option)
.then(result => {
record.defineId(result[0]["insertId"]);
record.saved();
});
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:37,代码来源:TaggingMariaDBAccessor.ts
示例9: memberInsertSql
private memberInsertSql(tagGroup: TagGroup): string {
let sql: string = "";
for (const tag of tagGroup.member) {
sql += mysql.format(
"INSERT INTO tag_group_member (tagGroupId, tagId) VALUES (?, ?);",
[tagGroup.id, tag.id]
);
}
return sql;
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:15,代码来源:TagGroupMariaDBContainer.ts
示例10: update
update(tagging: Tagging, option?: MariaDBBase.QueryOption): Promise<void> {
// weightだけ更新する
let sql: string
= "UPDATE tagging SET weight = ?" // tagging.weight
+ " WHERE taggingId = ?;"; // tagging.id
// プレースホルダに代入
sql = mysql.format(sql, [
tagging.weight,
tagging.id
]);
// クエリ実行
return this.executeUpdate(sql, option)
.then(() => tagging.saved());
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:17,代码来源:TaggingMariaDBAccessor.ts
示例11: remove
remove(tagging: Tagging, option?: MariaDBBase.QueryOption): Promise<void> {
let sql: string
// taggingテーブルからの削除
= "DELETE FROM tagging WHERE taggingId = ?; "// tagging.id
// tagging_recordテーブルからの削除
+ "DELETE FROM tagging_record"
+ " WHERE itemId = ?" // tagging.tagId
+ " AND tagId = ?;"; // tagging.itemId
sql = mysql.format(sql, [
tagging.id,
tagging.tagId,
tagging.itemId
]);
return this.executeUpdate(sql, option);
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:19,代码来源:TaggingMariaDBAccessor.ts
示例12: insert
insert(tagging: Tagging, option?: MariaDBBase.QueryOption): Promise<void> {
// INSERT文作成
let sql: string
= "INSERT INTO tagging(itemId, tagId, weight) VALUES(?, ?, ?);";
// プレースホルダに値を入れる
sql = mysql.format(sql, [
tagging.itemId,
tagging.tagId,
tagging.weight
]);
// クエリ実行
return this.query(sql, option)
.then(result => {
tagging.defineId(result["insertId"]);
tagging.saved();
});
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:20,代码来源:TaggingMariaDBAccessor.ts
示例13: VALUES
.then(result => {
const insertId: number = result["insertId"];
log.defineId(insertId);
let sql2: string = "";
for (const mmNum in log.meshinatorMessages) {
sql2 += mysql.format(
"INSERT INTO meshinator_message(logId, num, message) VALUES (?, ?, ?);",
[
insertId,
mmNum,
log.meshinatorMessages[mmNum]
]
);
}
if (sql2) {
return self.executeUpdate(sql2, option);
} else {
return Promise.resolve();
}
})
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:22,代码来源:RequestLogMariaDBContainer.ts
示例14: insert
insert(question: Question, option?: MariaDBBase.QueryOption): Promise<void> {
let qType: string;
if (question instanceof NiceToMeetYouQuestion) {
qType = "NiceToMeetYou";
} else if (question instanceof ModeSelectQuestion) {
qType = "ModeSelect";
} else if (question instanceof SimpleTagQuestion) {
qType = "SimpleTag";
} else if (question instanceof SimpleItemRecommendQuestion) {
qType = "SimpleItemRecommend";
} else if (question instanceof ContinueRecommendQuestion) {
qType = "ContinueRecommend";
} else if (question instanceof TagGroupQuestion) {
qType = "TagGroup";
} else if (question instanceof UnimplementedQuestion) {
qType = "Unimplemented";
}
const sql: string = mysql.format(
"INSERT INTO question (type, about, contextId, closed) VALUES (?, ?, ?, ?);",
[qType, question.about, question.contextId, question.isClosed]
);
return this.query(sql, option)
.then(result => {
question.defineId(result["itemId"]);
question.saved();
});
}
开发者ID:Huruikagi,项目名称:Meshinator,代码行数:38,代码来源:QuestionMariaDBContainer.ts
示例15: query
query(queryStr: string, params?: any[]): Promise<any> {
return this.manager.query(params ? mysql.format(queryStr, params) : queryStr)
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:3,代码来源:db.ts
示例16: fn
export function format<A>(
data: A,
{ queryString, params }: CompiledQuery<A>
) {
return Mysql.format(queryString, params.map(fn => fn(data)));
}
开发者ID:Schniz,项目名称:cuery,代码行数:6,代码来源:mysql.ts
示例17: logQuery
logQuery(sql: string, inserts: any = []) {
console.log(format(sql, inserts));
}
开发者ID:chasidic,项目名称:mysql,代码行数:3,代码来源:MysqlConnection.ts
示例18: prepareQuery
protected prepareQuery(query: string, variables: Array<string>): string {
return mysql.format(query, variables);
}
开发者ID:fabianTMC,项目名称:smart-query-cache,代码行数:3,代码来源:mysql.ts
示例19: execute
export async function execute(queryStr: string, params?: any[]): Promise<any> {
const conn = await getConnection()
return conn.query(params ? mysql.format(queryStr, params) : queryStr)
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:4,代码来源:db.ts
注:本文中的mysql.format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论