Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/merlinstardust/meteor-proxy-store
A local Mongo store wrapped by a Proxy
https://github.com/merlinstardust/meteor-proxy-store
Last synced: 15 days ago
JSON representation
A local Mongo store wrapped by a Proxy
- Host: GitHub
- URL: https://github.com/merlinstardust/meteor-proxy-store
- Owner: merlinstardust
- Created: 2018-07-19T20:22:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-20T19:08:02.000Z (over 6 years ago)
- Last Synced: 2024-11-12T18:48:36.465Z (2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mongo Proxy Store
A local Mongo store wrapped by a Proxy. By using a Proxy, you can store values in a local Mongo collection via object dot notation.
## Use
You can import store either as the default or the traditional Meteor destructured import.
You can get values from the store with destructuring (`const {groceries} = store`) or with traditional dot notation (`store.count`).
You can set values in the store via dot notation (`store.count = 1`).
You can also get and set values up to 1 layer deep (`store.keys.shed`)
### Get Values
```
// GroceryList.container.js
import store from 'meteor/merlin:proxy-store';
// import {store} from 'meteor/merlin:proxy-store';
import {withTracker} from 'meteor/react-meteor-data';
import GroceryList from './GroceryList';export default withTracker(() => {
const {groceries} = store;return {
count: store.count,
groceries,
};
})(GroceryList);
```### Set Values
```
// addItem.js
import store from 'meteor/merlin:proxy-store';const addItem = (item) => {
store.count += 1;
store.groceries = store.groceries.concat(item);
};
```