CREATE AGGREGATE array_agg(anyelement) ( SFUNC=array_append, STYPE=anyarray, INITCOND='{}' );
вторник, 8 февраля 2011 г.
aggregate function array_agg in postgresql 8.3
function idx in postgresql 8.3
CREATE OR REPLACE FUNCTION idx(anyarray, anyelement) RETURNS int AS $$ SELECT i FROM ( SELECT generate_series(array_lower($1,1),array_upper($1,1)) ) g(i) WHERE $1[i] = $2 LIMIT 1; $$ LANGUAGE sql IMMUTABLE;
воскресенье, 6 февраля 2011 г.
node.js+postgresql
List of postgresql adapters for node.js:
https://github.com/ry/node_postgres
https://github.com/brianc/node-postgres - my select (the best)
https://github.com/creationix/postgres-js
https://github.com/aurynn/postgres-js
I execute command for use node-postgres:
var pg = require('pg');
var connectionString = "pg://postgres:postgres@localhost:5432/test";
pg.connect(connectionString, function(err, client) {
if (err) {
console.log('fatal error');
} else {
client.query("select version();", function(err, result) {
if (err) {
console.log('error');
} else {
console.log(result);
}
});
}
})
https://github.com/ry/node_postgres
https://github.com/brianc/node-postgres - my select (the best)
https://github.com/creationix/postgres-js
https://github.com/aurynn/postgres-js
I execute command for use node-postgres:
npm install pg example.js:var pg = require('pg');
var connectionString = "pg://postgres:postgres@localhost:5432/test";
pg.connect(connectionString, function(err, client) {
if (err) {
console.log('fatal error');
} else {
client.query("select version();", function(err, result) {
if (err) {
console.log('error');
} else {
console.log(result);
}
});
}
})
Подписаться на:
Комментарии (Atom)