Isomorphic PostgreSQL client for [node](http://nodejs.org)
npm install prostgles-serverIsomorphic PostgreSQL client for node


!Tests

- CRUD operations with end-to-end type safety
- Auto-Generated TypeScript Definition for Database schema
- Subscriptions to data and schema changes
- Fine grained access control
- Optimistic data replication
``bash`
$ npm install prostgles-server
`typescript
import prostgles from "prostgles-server";
prostgles({
dbConnection: {
host: "localhost",
port: "5432",
user: process.env.PG_USER,
password: process.env.PG_PASS,
},
tsGeneratedTypesDir: __dirname,
onReady: async ({ dbo }) => {
const posts = await dbo.posts.find(
{ title: { $ilike: "%car%" } },
{
orderBy: { created: -1 },
limit: 10,
},
);
},
});
`
server.js
`js
const express = require("express");
const app = express();
const path = require("path");
var http = require("http").createServer(app);
var io = require("socket.io")(http);
http.listen(3000);
let prostgles = require("prostgles-server");
prostgles({
dbConnection: {
host: "localhost",
port: "5432",
user: process.env.PRGL_USER,
password: process.env.PRGL_PWD,
},
io,
publish: "*", // Unrestricted INSERT/SELECT/UPDATE/DELETE access to the tables in the database
onReady: async ({ dbo }) => {},
});
`
react.tsx
`jsx`
const App = () => {
const { isLoading, dbo } = useProstglesClient();
if (isLoading) return null;
return <>Database tables: {Object.keys(dbo)}>;
};
./public/index.html
`html
src="https://unpkg.com/socket.io-client@latest/dist/socket.io.min.js"
type="text/javascript"
>
src="https://unpkg.com/prostgles-client@latest/dist/index.js"
type="text/javascript"
>