本文整理匯總了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();
});