kucukkanat / localdb Goto Github PK
View Code? Open in Web Editor NEWMongoDB on the browser. A database using Javascript localStorage
License: MIT License
MongoDB on the browser. A database using Javascript localStorage
License: MIT License
If id
key is required for further interactions with that "document", whether db.insert()
must throw an exception or generate a random id
(as it does now) but return that auto-generated id
if we omit that field.
Where is the API documentation? Simple .insert
, query
and remove
is on the README.md but we need full API.
db.insert({my: 'value'});
works and generates a random id
, but following call is not working at all:
db.insert({id: 'hello', my: 'value'});
I created a database with
foo = new DB('foo');
bar = new DB('bar');
and now I need to purge/delete/vanish whole foo
database but keep bar
database. How can I do that?
Hi,
I like to have upsert function something like the below. Can this be added, please?
This code will take json as param, and then will check if already exists, if not it will do the insert operation based on the given id. If already exist, then it will upate.
upsert(object) {
if(object.id === undefined)
{
object.id = guid()
}
const foundObjects = sift({id: object.id}, JSON.parse(localStorage[this.name]));
if(foundObjects.length==0)
{
let table = JSON.parse(localStorage[this.name])
table.push(object)
localStorage[this.name] = JSON.stringify(table)
this.emit('$insert',object)
this.emit('$create',object)
return object
}
return this.update({id: object.id}, object);
}
Hi,
The document reads as follows
If object has an .id property,
However, if I have id
or _id
or .id
it always generate id its own. It is possible to create with my own id
?
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.