{"id":19083716,"url":"https://github.com/deepstreamio/deepstream.io-storage-postgres","last_synced_at":"2025-04-30T08:54:55.316Z","repository":{"id":13167449,"uuid":"73776189","full_name":"deepstreamIO/deepstream.io-storage-postgres","owner":"deepstreamIO","description":"Postgres Database connector for deepstream.io","archived":false,"fork":false,"pushed_at":"2023-10-20T01:15:18.000Z","size":1052,"stargazers_count":20,"open_issues_count":3,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T17:22:46.191Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepstreamIO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-15T04:29:41.000Z","updated_at":"2024-03-11T23:59:10.000Z","dependencies_parsed_at":"2023-01-13T17:20:18.939Z","dependency_job_id":null,"html_url":"https://github.com/deepstreamIO/deepstream.io-storage-postgres","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepstreamIO%2Fdeepstream.io-storage-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepstreamIO%2Fdeepstream.io-storage-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepstreamIO%2Fdeepstream.io-storage-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepstreamIO%2Fdeepstream.io-storage-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepstreamIO","download_url":"https://codeload.github.com/deepstreamIO/deepstream.io-storage-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223780069,"owners_count":17201287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T02:48:51.809Z","updated_at":"2024-11-09T02:48:52.305Z","avatar_url":"https://github.com/deepstreamIO.png","language":"TypeScript","readme":"# deepstream.io-storage-postgres\n\nPostgres Database connector for deepstream.io\n\nThis connector is automatically installed when using the deepstream server \u003e v5. It can also be installed via the deepstream command line interface via\n\n```\ndeepstream install storage postgres\n```\n\nand can be configured in the `storage` section of deepstreams config.yml. Supported options are\n\n```yaml\nstorage:\n  name: postgres\n  options:\n    user: some-user\n    database: some-database\n    password: some-password\n    host: localhost\n    port: 5432 #postgres default post\n    schema: ds #schema defaults to ds. Will be created if it doesn't exist\n    defaultTable: default # default table name defaults to default\n    max: 10 #concurrent connections\n    idleTimeoutMillis: 30000 #timeout after which connection will be cut\n    writeInterval: 200 #amount of milliseconds during which writes will be buffered\n    useJsonb: false #store values as searchable binary JSON (slower)\n    notifications:\n      CREATE_TABLE: false #Get notified when tables are created\n      DESTROY_TABLE: false #Get notified when tables are dropped\n      INSERT: false # Get notified when records are created\n      UPDATE: false # Get notified when records are updated\n      DELETE: false # Get notified when records are deleted\n```\n\nThis connector can also be used as a standalone component from node.js to connect to postgres' notification mechanism. To do this, install the connector via\n\n```\nnpm install @deepstream/storage-postgres\n```\n\nand instantiate it directly\n\n```javascript\nconst { Connector } = require( '@deepstream/storage-postgres' );\nconst settings = {\n  user: process.env.PG_USER,\n  database: process.env.PG_DB,\n  password: process.env.PG_PASSWORD,\n  host: process.env.PG_HOST,\n  port: parseInt( process.env.PG_PORT, 10 )\n}\n\nconst connector = new Connector( settings )\n\n// start connector\nconnector.init()\n\nconnector.on( 'ready', ()=\u003e{\n    connector.subscribe( event =\u003e{\n        //event will be a map of event and table for CREATE_TABLE and DESTROY_TABLE\n        // { event: 'CREATE_TABLE', table: 'some-table' })\n        // or of event, table and key for INSERT, UPDATE AND DELETE, e.g.\n        // { event: 'INSERT', table: 'some-table', key: 'some-key' }\n    }, err =\u003e { if( err ) throw err; })\n\n    //subscriptions can be removed\n    connector.unsubscribe(( err )=\u003e{ /* done */ })\n\n    // the connector also comes with a facility to get a map of all tables and the numbers of items within\n    connector.getSchemaOverview(( err, result ) =\u003e {\n        /* result will be e.g.\n        {\n            'some-table': 2,\n            'some-other-table': 1,\n            'new-table': 1,\n            'table-a': 2,\n            'table-b': 2\n        }\n        */\n    })\n})\n```\n\n## Migrating to the latest connector version\n\nThe latest connector version (3.x) introduces breaking changes at database level for a cleaner data structure: one column for id, one for version, one for value.\n\nFor migrating a current database from the v2 connector to v3 check out [this script](https://gist.github.com/jaime-ez/68353c7dfbd00decbcfd6ab394cfb2a8)\n\n## Installing the previous connector version\n\n`npm i @deepstream/storage-postgres@2.0.1`\n\n## Deepstream v3 users\n\nFor user of the deepstream server version 3.x, install the connector with `npm install deepstreamIO/deepstream.io-storage-postgres#v1.1.5`.\n\nRequire as `require( 'deepstream.io-storage-postgres' )`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepstreamio%2Fdeepstream.io-storage-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepstreamio%2Fdeepstream.io-storage-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepstreamio%2Fdeepstream.io-storage-postgres/lists"}