本文整理汇总了TypeScript中pg.Client.end方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.end方法的具体用法?TypeScript Client.end怎么用?TypeScript Client.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pg.Client
的用法示例。
在下文中一共展示了Client.end方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: resolve
client.query('UPDATE places SET modified = LOCALTIMESTAMP WHERE description = \'' + input + '\'', (error, result) => {
if(error) reject(error)
if(result.rowCount) {
resolve('OK')
}
client.end()
})
示例2: Client
export async function query<T>(config: ConnectionConfig, queryText: string, values: any[] = []) {
const client = new Client(config)
await client.connect()
const result = await client.query(queryText, values)
await client.end()
return result as QueryResult<T>
}
示例3: reject
await new Promise<void>((resolve, reject) => connection.end((err) => {
if (err) {
reject(err);
} else {
resolve();
}
}));
示例4: NOW
client.query("SELECT NOW() AS 'theTime'", (err, result) => {
if (err) {
return console.error("Error running query", err);
}
console.log(result.rows[0]["theTime"]);
client.end();
return null;
});
示例5: async
const run = async () => {
const dbCreate = new Client({})
await dbCreate.connect()
try {
await dbCreate.query('drop database gandalf_test')
} catch (err) {
console.log('drop err', err.message)
}
await dbCreate.query('create database gandalf_test')
await dbCreate.end()
await client.connect()
await createPersons()
.then(createCompanies)
.then(createProducts)
.then(createOrders)
.then(createViews)
await client.end()
}
示例6: testSchema
async function testSchema(sql: string) {
const client = new Client(connectionDetails)
await client.connect()
await client.query('DROP SCHEMA IF EXISTS DatabaseIntrospector cascade;')
await client.query('CREATE SCHEMA DatabaseIntrospector;')
await client.query('SET search_path TO DatabaseIntrospector;')
await client.query(sql)
expect(await introspect()).toMatchSnapshot()
await client.end()
}
示例7: http
var request = (pokemon:number) => {
if (pokemon <= maxPokemon) {
http(endpoint + pokemon, (err, response, body) => {
if (err) console.log(err);
else if (body) {
var pokemonData = JSON.parse(body);
console.log(pokemonData.name);
client.query(insertQuery.replace(/\?/g, (char:string, position:number, word:string) =>
word.indexOf(char) === position ? pokemonData.national_id : pokemonData.name
), (err, res) => {
if (!err) request(++pokemon);
else console.log(err);
});
}
});
} else {
console.log("Finished querying");
client.end();
}
};
示例8:
client.query('SELECT $1::text as name', ['brianc'], (err, res) => {
if (err) throw err;
console.log(res);
client.end();
});
示例9: NOW
client.query('SELECT NOW()', (err, res) => {
if (err) throw err;
console.log(res);
client.end();
});