{"id":13801527,"url":"https://github.com/UnmaintainedProjects/pls","last_synced_at":"2025-05-13T11:31:19.091Z","repository":{"id":57747378,"uuid":"522856013","full_name":"UnmaintainedProjects/pls","owner":"UnmaintainedProjects","description":"Preserve `localStorage` in databases.","archived":false,"fork":false,"pushed_at":"2022-08-13T07:49:37.000Z","size":9,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-13T04:02:27.378Z","etag":null,"topics":["deno","localstorage","mongo","postgres","redis"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UnmaintainedProjects.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-08-09T07:59:15.000Z","updated_at":"2024-01-18T21:49:01.000Z","dependencies_parsed_at":"2022-09-06T00:20:10.406Z","dependency_job_id":null,"html_url":"https://github.com/UnmaintainedProjects/pls","commit_stats":null,"previous_names":["roj1512/pls","leastsignificant/pls","my-abandoned-projects/pls","unmaintainedprojects/pls"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnmaintainedProjects%2Fpls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnmaintainedProjects%2Fpls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnmaintainedProjects%2Fpls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnmaintainedProjects%2Fpls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnmaintainedProjects","download_url":"https://codeload.github.com/UnmaintainedProjects/pls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932868,"owners_count":21986468,"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":["deno","localstorage","mongo","postgres","redis"],"created_at":"2024-08-04T00:01:23.901Z","updated_at":"2025-05-13T11:31:16.313Z","avatar_url":"https://github.com/UnmaintainedProjects.png","language":"TypeScript","funding_links":[],"categories":["Modules"],"sub_categories":["Utils"],"readme":"# PLS [![](https://shield.deno.dev/x/pls)](https://deno.land/x/pls)\n\n\u003e Preserve `localStorage` in databases.\n\n## Features\n\n- No adapter dependency is loaded by default.\n- Possible to write/contribute your own adapters.\n- Currently providing ready-to-use adapters for MongoDB, PostgreSQL and Redis.\n\n## Get Started\n\n```ts\nimport { setup } from \"https://deno.land/x/pls/mod.ts\";\n```\n\n### Automatic\n\nYou can set the `PLS_CONNECTION_URI` environment variable to a MongoDB,\nPostgreSQL or Redis connnection URI, and simply call `setup()` without any\narguments:\n\n```ts\nawait setup();\n```\n\n### MongoDB\n\n```ts\nimport { MongoClient } from \"https://deno.land/x/mongo/mod.ts\";\nimport { MongoAdapter } from \"https://deno.land/x/pls/adapters/mongo.ts\";\n\nconst client = new MongoClient();\n\n...\nawait client.connect(...)\n...\n\nconst collection = client.database(\"deno\").collection(\"localStorage\");\n\nawait setup({\n  adapter: new MongoAdapter(collection),\n});\n```\n\n### PostgreSQL\n\n```ts\nimport { Client } from \"https://deno.land/x/postgres/mod.ts\";\nimport { PostgresAdapter } from \"https://deno.land/x/pls/adapters/postgres.ts\";\n\nconst client = new Client(...);\n\n...\nawait client.connect()\n...\n\nconst table = \"localStorage\";\n\nawait setup({\n  adapter: await new PostgresAdapter(client, table).initialize(),\n});\n```\n\n### Redis\n\n```ts\nimport { connect } from \"https://deno.land/x/redis/mod.ts\";\nimport { RedisAdapter } from \"https://deno.land/x/pls/adapters/redis.ts\";\n\nconst redis = await connect(...);\n\nawait setup({\n  adapter: new RedisAdapter(redis),\n});\n```\n\nAfter that, you’ll just use `localStorage` as you normally would, and...\n\nEverything will be synchronized with your database!\n\n## TTL\n\nBy default, `localStorage` will be checked every 20 seconds to see if there were\nany changes were made to it, and if there were, they will get pushed to the\ndatabase adapter you provided when calling `setup()`.\n\nYou can configure the duration, or just disable it and call the flush method\nwhenever you like.\n\n### Configuring\n\n```ts\nawait setup({\n  ttl: 30000, // in milliseconds\n});\n```\n\n\u003e Note that you should not set it too low, otherwise you may face unexpected\n\u003e problems.\n\n### Disabling\n\n```ts\nawait setup({ ttl: null });\n```\n\nYou can then call `flush()` whenever you’d liked to synchronize:\n\n```ts\nimport { flush } from \"https://deno.land/x/pls/mod.ts\";\n\nflush();\n```\n\n## Including/excluding\n\nYou can decide on which keys of pattern of keys should be included or excluded\nwhen persisting them:\n\n```ts\nawait setup({\n  include: [\"someSpecificKeyToInclude\", /^someRegExpToInclude/],\n  exclude: [\"someSpecificKeyToExclude\", /someRegExpToExclude$/],\n});\n```\n\n---\n\nWritten by [@roj1512](https://github.com/roj1512). Under [WTFPL](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnmaintainedProjects%2Fpls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUnmaintainedProjects%2Fpls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnmaintainedProjects%2Fpls/lists"}