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

Explore cockroach db support #160

@dustinsmith1024

Description

@dustinsmith1024

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 } ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions