Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nsisodiya/cloud-variables-demo
WIP
https://github.com/nsisodiya/cloud-variables-demo
Last synced: 28 days ago
JSON representation
WIP
- Host: GitHub
- URL: https://github.com/nsisodiya/cloud-variables-demo
- Owner: nsisodiya
- License: mit
- Created: 2019-06-06T04:33:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T07:58:39.000Z (over 3 years ago)
- Last Synced: 2024-04-14T07:51:19.062Z (8 months ago)
- Language: JavaScript
- Size: 158 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cloud-variables-demo
Work in Progress ! Most simple but unsecured way to bypass REST API and sync client side variables in MongoDB.# Imagination on API.
```js
import CloudVariables from "cloud-variables";// Initialise
var cv = new CloudVariables({
driver: "MONGO",
userId: "dTDdfrFDE$RFDcGTFERRFFde45tfGVC" //Per user we want to store
});var todoList = await cv.Array("todo");
// This will actually bind a todoList Collection from MongoDB
// If collection not found on backend, it will throw error.//var previousItem = await todoList.getById("jiu936"); // This will load item from remote DB to this variable.
console.log('Print Length', todoList.length);var firstItem = await todoList.push({
task: "Visit Tibbat",
done: false
});
console.log('this is true', firstItem.task === "Visit Tibbat");var secItem = await todoList.push({
task: "Write Book",
done: false
});
todoList.map(function(v) {
console.log("Listing all the items in the collections", v);
});// Modify particular item.
var thirdItem = todoList[2];
await thirdItem.update({
task: "Plant a tree"
});
// This should merge with exisiting keys.///
var globalSettings = await cv.Object("settings");
await globalSettings.update({
lang: "hi",
theme: "dark"
})
console.log("must be true", globalSettings.lang === 'hi');
console.log("must be true", globalSettings.theme === 'dark');var myPersonalData = await cv.Object("myPersonalData");
await myPersonalData.update({
email: "[email protected]",
coder: true
});```
# TODO Think
- add server side validation will in server code.