{"id":"ratplier/silo","name":"silo","scope":"ratplier","platform":"roblox","description":"an atomic datastore library","version":"1.1.0","latest":"1.1.0","versions":["1.0.0","1.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"5f6c3ecab75ee85d5e6a7876e2621bb19039defb56857b928428ea976d0e0e7d","likes":0,"downloads":0,"install":"forest install ratplier/silo","url":"https://forest.dev/p/roblox/ratplier/silo","files":"https://api.forest.dev/ai/package/roblox/ratplier/silo/files","readme":"# silo\r\n\r\nan atomic datastore library\r\n\r\ninstall via wally:\r\n\r\n```toml\r\nsilo = \"ratplier/silo@1.1.0\"\r\n```\r\n\r\nquickstart\r\n\r\n```luau\r\nconst schema = silo.schema {\r\n    coins = 10,\r\n    is_premium = false,\r\n}\r\nconst store = silo.store(schema, silo.backends.temporary(\"player_data\"))\r\n\r\nstore:update(\"ratplier\", function(data)\r\n    if data.coins < 10 then\r\n        return nil\r\n    end\r\n\r\n    data.coins -= 10\r\n    data.is_premium = true\r\n    return data\r\nend)\r\n```\r\n\r\n## documentation\r\n\r\n- [backend](/docs/backend.luau) - guide to creating custom backends for `silo`\r\n- [schema](/docs/schema.luau) - quick explaination on `schemas` and `migration`\r\n- [transactions](/docs/transactions.luau) - the rundown on `update` and `tx`\r\n\r\n## api\r\n\r\n```luau\r\nsilo.store(schema, backend)\r\n```\r\n\r\n- `.update(key, transform)` - apply an atomic update to a record\r\n- `.tx(callback)` - execute multiple updates in a transaction\r\n- `.observe(callback)` - subscribe to key changes\r\n- `.view(key)` - get a live view object for a key\r\n- `.erase(key)` - delete a record\r\n\r\n```luau\r\nsilo.schema(default)\r\n```\r\n\r\n- `.migration(transform)` - create a migration for the schema\r\n\r\n```luau\r\nsilo.backends\r\n```\r\n\r\n- `temporary` - memory backend for testing\r\n- `datastore` - Roblox Datastore backend\r\n","readmeTruncated":false}