Skip to content

Commit

Permalink
Merge pull request #47 from outerbase/bwilmoth/schema-refactor
Browse files Browse the repository at this point in the history
Update connections to use latest schema models
  • Loading branch information
Brayden committed Aug 28, 2024
2 parents 1e43c05 + e248b23 commit 61b4b12
Show file tree
Hide file tree
Showing 5 changed files with 754 additions and 135 deletions.
39 changes: 16 additions & 23 deletions playground/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { CloudflareD1Connection, Outerbase, NeonHttpConnection, OuterbaseConnection, equalsNumber, equals } from '../dist/index.js';
import { CloudflareD1Connection, Outerbase } from '../dist/index.js';
import express from 'express';
import { ColumnDataType } from '../dist/query-builder/index.js';

const app = express();
const port = 4000;

app.get('/test/cloudflare', async (req, res) => {
app.get('/test', async (req, res) => {
// Establish connection to your provider database
const d1 = new CloudflareD1Connection({
apiKey: '',
Expand All @@ -16,9 +15,11 @@ app.get('/test/cloudflare', async (req, res) => {
const db = Outerbase(d1);
// const dbSchema = await d1.fetchDatabaseSchema()

// const { data, query } = await db.selectFrom([
// { table: 'test2', columns: ['*'] }
// ]).query()
// const { data, query } = await db
// .selectFrom([
// { table: 'test2', columns: ['*'] }
// ])
// .query()

// let { data, query } = await db
// .insert({ fname: 'John' })
Expand All @@ -37,15 +38,15 @@ app.get('/test/cloudflare', async (req, res) => {
// .where(equals('id', '3'))
// .query();

let data = {}
let query = await db
.createTable('test3')
.schema('public')
.columns([
{ name: 'id', type: ColumnDataType.NUMBER, primaryKey: true },
{ name: 'fname', type: ColumnDataType.STRING }
])
.toString();
// let data = {}
// let query = await db
// .createTable('test3')
// .schema('public')
// .columns([
// { name: 'id', type: ColumnDataType.NUMBER, primaryKey: true },
// { name: 'fname', type: ColumnDataType.STRING }
// ])
// .toString();

// let data = {}
// let query = await db
Expand All @@ -57,14 +58,6 @@ app.get('/test/cloudflare', async (req, res) => {
// .dropTable('test4')
// .toString();

console.log('Running Query: ', query)

// db.
// - ACTION
// - CONDITIONS
// - RETURNING
// - query() / toString()

// let { data } = await db.queryRaw('SELECT * FROM playing_with_neon WHERE id = $1', ['1']);
res.json(data);
});
Expand Down
Loading

0 comments on commit 61b4b12

Please sign in to comment.