Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Explore cockroach db support #160

Open
dustinsmith1024 opened this issue Jan 14, 2020 · 0 comments
Open

Explore cockroach db support #160

dustinsmith1024 opened this issue Jan 14, 2020 · 0 comments

Comments

@dustinsmith1024
Copy link
Contributor

dustinsmith1024 commented Jan 14, 2020

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:[email protected]: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 } ]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant