{"id":22514720,"url":"https://github.com/jdizm/node-express-bookshelf-pg","last_synced_at":"2025-12-30T20:31:50.105Z","repository":{"id":177095548,"uuid":"512218288","full_name":"JDIZM/node-express-bookshelf-pg","owner":"JDIZM","description":"A demo node/express API project using bookshelf, knex and postgres with schema migrations","archived":false,"fork":false,"pushed_at":"2023-07-02T18:45:31.000Z","size":109,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T03:27:45.275Z","etag":null,"topics":["api","bookshelf","express","knex","node","nodejs","postgres","sql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JDIZM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-09T15:21:14.000Z","updated_at":"2024-02-24T10:13:34.000Z","dependencies_parsed_at":"2023-07-25T17:15:46.756Z","dependency_job_id":null,"html_url":"https://github.com/JDIZM/node-express-bookshelf-pg","commit_stats":null,"previous_names":["jdizm/bookshelf-postgres","jdizm/node-express-bookshelf-pg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDIZM%2Fnode-express-bookshelf-pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDIZM%2Fnode-express-bookshelf-pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDIZM%2Fnode-express-bookshelf-pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDIZM%2Fnode-express-bookshelf-pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JDIZM","download_url":"https://codeload.github.com/JDIZM/node-express-bookshelf-pg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245954341,"owners_count":20699812,"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":["api","bookshelf","express","knex","node","nodejs","postgres","sql"],"created_at":"2024-12-07T03:20:51.613Z","updated_at":"2025-12-30T20:31:50.077Z","avatar_url":"https://github.com/JDIZM.png","language":"JavaScript","readme":"# bookshelf-postgres\n\n- node\n- [bookshelf](https://bookshelfjs.org/)\n- [knex](https://knexjs.org/guide/migrations.html)\n- postgres\n- express\n- pnpm\n\n\n## Installation\n\n### package manager\n\nThis project uses pnpm to manage dependencies. Install pnpm with `npm install -g pnpm` and run `pnpm install` to install dependencies.\n\nsee https://pnpm.io/installation for more information on pnpm.\n\n### volta\n\nThis project uses volta to manage node versions. Install volta and run `volta install` to install the correct node version.\n\nTo install volta run the following command in the terminal.\n\n```\ncurl https://get.volta.sh | bash\n```\n\n\n## setup\n\n1. install the project dependencies `pnpm install`\n2. create a `.env` file with the contents of `.env.example`\n3. `knex migrate:latest`\n4. `knex seed:run`\n5. `npm run dev`\n6. test the api endpoints work with [VSCode REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client)\n\n## importing the db\n\nimports a db from local `backup.sql` file\n\n```\nnpm run db:drop\nnpm run db:create\nnpm run db:import\n```\n\nalternatively you can copy the db to the container with `npm run db:copy` and from the shell you can import the db with:\n\n```\npsql -U postgres -d \u003cdbname\u003e \u003c backup.sql\n```\n\nIf you encounter\n`ERROR: invalid byte sequence for encoding \"UTF8\": 0xff`\n\nSimply create a new backup.sql file and copy the contents of the old file into a new file.\nThen run the import scripts.\n\nalso check the collation of your db if you encounter issues\n\n```\necho $LANG\n`en_US.utf8` or `en_GB.UTF-8`\n\nexport LANG=en_GB.UTF-8\n```\n\n## backing up the db\n\nto backup the db simply run `npm run db:backup` this will run the following command on the docker container\n\n```\ndocker exec \u003cdb-container-name\u003e /usr/bin/pg_dump -U \u003cdbuser\u003e \u003cdbname\u003e \u003e backup.sql\n```\n\n## adding new tables\n\nyou will need to create new tables with a migration or with a custom script\n\n## migrations with knex\n\nto use migrations install knex globally `npm install -g knex`\n\n- https://www.jsparling.com/set-up-bookshelf-js-for-node-js/\n- https://knexjs.org/guide/schema-builder.html#datetime\n\nYou can create and run migrations with the knex cli.\n\n1. create a migration `knex migrate:make create_table`\n2. add logic to the migration file to create required tables\n3. run the migration `knex migrate:latest` to update the db with new tables\n\n## seeds\n\nyou can see the database with data; the migrations will only create the required tables\n\nTo run a seed use `npm run seed:run` to run the seed file\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdizm%2Fnode-express-bookshelf-pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdizm%2Fnode-express-bookshelf-pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdizm%2Fnode-express-bookshelf-pg/lists"}