Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/efishery/pouchy-store
Libraries to ease pouch-couch stack on offline first app
https://github.com/efishery/pouchy-store
offline pouchdb react
Last synced: 2 months ago
JSON representation
Libraries to ease pouch-couch stack on offline first app
- Host: GitHub
- URL: https://github.com/efishery/pouchy-store
- Owner: eFishery
- License: mit
- Created: 2019-03-11T08:52:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-15T03:57:38.000Z (almost 4 years ago)
- Last Synced: 2024-11-01T05:16:33.957Z (2 months ago)
- Topics: offline, pouchdb, react
- Language: JavaScript
- Size: 63.5 KB
- Stars: 12
- Watchers: 5
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Pouchy Store
Pouchy Store is a library to help developer create [Offline First](http://offlinefirst.org/) apps out of the box with synchronizing capabilities locally-remotely. Pouchy Store could be used for NodeJS/ReactJS and ReactNative. Pouchy Store built on top of PouchDB (local) and CouchDB (remote) stack.
## How To Use
Install this library using
`npm i pouchy-store`Import `PouchyStore` from library in your Model Class
```
import {PouchyStore} from 'pouchy-store';
import config from '../config';class ModelStore extends PouchyStore {
get name() {
return 'model';
}get urlRemote() {
return config.couchDBUrl;
}get optionsRemote() {
return {
auth: config.couchDBAuth,
};
}
}export default new ModelStore();
```
Use your model class in your app (React Example)
```
import ModelStore from './storage/modelstore';
import {UsePouchy} from 'pouchy-store';const Home = props => {
const [isInit, setInit] = useState(false);
const leadInitializing = async () => {
await ModelStore.initialize();
await ModelStore.initializeRemote();
setInit(true);
};
// you can use any options on couchDB query, and pouchDB-find
// fetch-id used to force-update when option changes
const [dataModel] = usePouchy(ModelStore, {
selector: {
_id: {
$eq: 'someUUID',
},
},
field: ['name','_id']
limit: 10,
sort: ['name'],
}, 'fetch-id');
useEffect(() => {
if (!isInit) {
initiate();
}
}, [isInit]);
return (
);
}
```
Available API for CRUD operation:
```
/* manipulation of array data */
addItem(payload)
addItemWithId(id, payload)
editItem(id, payload)
deleteItem(id)
```## Code Example
[Pouchy Store Example on React](https://github.com/eFishery/pouchy-store-example)## Contributor
[Dimas Gilang Saputra](https://github.com/sumartoyo)
[Anshorimuslim](https://github.com/ans-4175)## Credits
[PouchDB](https://pouchdb.com/)
[CouchDB](http://couchdb.apache.org/)
[React Native SQLite Storage](https://www.npmjs.com/package/react-native-sqlite-storage)## License
MIT