This repository was archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Explore cockroach db support #160
Copy link
Copy link
Open
Description
Just attempted a quick cockroach db connect and query. Initially it failed on the Postgres version check. I tweaked that function and queries started working.
Pushed to the cockroach branch. https://github.com/C2FO/patio/compare/cockroach?expand=1
var patio = require("../patio");
//set camelize = true if you want snakecase database columns as camelcase
patio.camelize = true;
// insecure mode password doesnt matter
const DB = patio.connect("cockroach://root:pass@127.0.0.1:26257/bank");
// console.log(DB);
const Accounts = patio.addModel("accounts");
// This works...
return DB.fetch("SELECT * FROM accounts").all().chain((data) => {
console.log(data);
}).chain(() => {
console.log("go sync")
return Accounts.sync().chain(() => {
console.log('synced...')
return Accounts.naked().all().chain((state) => {
console.log(state);
})
.chain(process.exit, function (err) {
console.log(err)
process.exit(1);
});
}, function(err) {
console.log(err);
process.exit();
});
});➜ node test.js
[ { id: '1', balance: 1000.5 },
{ id: '2', balance: 2000.5 },
{ id: '3', balance: 222.5 },
{ id: '4', balance: 222.56 } ]
go sync
19.2.2
synced...
[ { id: '1', balance: 1000.5 },
{ id: '2', balance: 2000.5 },
{ id: '3', balance: 222.5 },
{ id: '4', balance: 222.56 } ]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels