instapp / storagedb Goto Github PK
View Code? Open in Web Editor NEWMongoDB-like API for HTML5 Storage (localStorage and sessionStorage)
Home Page: https://instapp.github.io/storagedb
License: MIT License
MongoDB-like API for HTML5 Storage (localStorage and sessionStorage)
Home Page: https://instapp.github.io/storagedb
License: MIT License
Not sure if this project is still maintained, but I tried using it on a typescript project and it throws a TypeError: storagedb2_1.default is not a constructor
which causes compilation to fail. Maybe a .d.ts definitions file would be needed.
Line 292 in 6aa01e1
Hi,
I want to check whether DB and Collection already exists before I create them. Please advise how to achieve.
I want to check whether DB exists before I create it
const localStorageObj = new StorageDB({
storage: window.localStorage, // storage object, default is window.localStorage. If you want to store data in memory only, you can set it null
database: localStorage.getItem('appkey'), // database name, default is 'db'
primaryKey: 'id' // primary key of collection, default is '_id'
});
I want to check whether the collection is exists before create it
const UsercommentsTable = localStorageObj.get('UsercommentsTable');
It should be lib/storagedb.js
. code
Hi, I have been using this for my web projects. Recently, I have started one of my web application using React web framework. As I try to use the storagedb2, I'm getting the following error.
"storagedb2__WEBPACK_IMPORTED_MODULE_1___default.a is not a constructor"
Here is the detailed error.
"TypeError: storagedb2__WEBPACK_IMPORTED_MODULE_1___default.a is not a constructor
at Storage.returnDatabase (http://localhost:3000/static/js/main.chunk.js:321:16)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/0.chunk.js:7715:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/0.chunk.js:7764:20)
at invokeGuardedCallback (http://localhost:3000/static/js/0.chunk.js:7817:35)
at invokeGuardedCallbackAndCatchFirstError (http://localhost:3000/static/js/0.chunk.js:7832:29)
at executeDispatch (http://localhost:3000/static/js/0.chunk.js:7963:7)
at executeDispatchesInOrder (http://localhost:3000/static/js/0.chunk.js:7988:9)
at executeDispatchesAndRelease (http://localhost:3000/static/js/0.chunk.js:8091:9)
at executeDispatchesAndReleaseTopLevel (http://localhost:3000/static/js/0.chunk.js:8100:14)
at forEachAccumulated (http://localhost:3000/static/js/0.chunk.js:8072:12)
at runEventsInBatch (http://localhost:3000/static/js/0.chunk.js:8117:7)
at runExtractedPluginEventsInBatch (http://localhost:3000/static/js/0.chunk.js:8259:7)
at handleTopLevel (http://localhost:3000/static/js/0.chunk.js:13212:9)
at batchedEventUpdates$1 (http://localhost:3000/static/js/0.chunk.js:31720:16)
at batchedEventUpdates (http://localhost:3000/static/js/0.chunk.js:8795:16)
at dispatchEventForPluginEventSystem (http://localhost:3000/static/js/0.chunk.js:13308:9)
at attemptToDispatchEvent (http://localhost:3000/static/js/0.chunk.js:13425:9)
at dispatchEvent (http://localhost:3000/static/js/0.chunk.js:13328:23)
at unstable_runWithPriority (http://localhost:3000/static/js/0.chunk.js:42699:16)
at runWithPriority$2 (http://localhost:3000/static/js/0.chunk.js:19587:14)
at discreteUpdates$1 (http://localhost:3000/static/js/0.chunk.js:31737:16)
at discreteUpdates (http://localhost:3000/static/js/0.chunk.js:8820:16)
at dispatchDiscreteEvent (http://localhost:3000/static/js/0.chunk.js:13295:7)"
Here is my React component
import React from "react";
import StorageDB from 'storagedb2'
class Storage extends React.Component{
constructor(props, context) {
super(props, context);
this.state = {
name:'John'
}
this.returnDatabase = this.returnDatabase.bind(this);
};
returnDatabase()
{
const db = new StorageDB({
storage: window.localStorage, // storage object, default is window.localStorage. If you want to store data in memory only, you can set it null
database: 'testdb', // database name, default is 'db'
primaryKey: 'id' // primary key of collection, default is '_id'
});
const Users = db.get("Users");
Users.insert({'a':1});
}
render(){
return <div>Storage <button onClick={this.returnDatabase}>Click me</button></div>
}
}
export default Storage;
Please advise how to solve this issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.