mwater / minimongo Goto Github PK
View Code? Open in Web Editor NEWClient-side in-memory mongodb backed by localstorage with server sync over http
License: GNU Lesser General Public License v3.0
Client-side in-memory mongodb backed by localstorage with server sync over http
License: GNU Lesser General Public License v3.0
...is it supposed to be used with some other REST API?
Is it possible to have a c++ server with the mongoDB driver expose an API for minimongo to interact with?
Upsert when uploaded should update the local copy.
Common feature with less-than-simple work-arounds.
So the main problem in react native is to find the compatiable library to support offline+sync. Does it support react native?
Are there typings for minimongo ?
Allow filtering of which to uncache. Ignore upserts or removes
Using find() does return an object with fetch() and the callback is not executed.
I need a way to keep in sync the local indexeddb and the remote mongodb. I think I could use the HybridDB to get this working but I can't understand how does it work...
Could be possible have an usage example of this function?
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Prototype Pollution
Package lodash
Patched in >=4.17.11
Dependency of minimongo
Path minimongo > lodash
More info https://nodesecurity.io/advisories/782
Low Prototype Pollution
Package lodash
Patched in >=4.17.5
Dependency of minimongo
Path minimongo > lodash
More info https://nodesecurity.io/advisories/577
found 2 vulnerabilities (1 low, 1 high) in 72 scanned packages
2 vulnerabilities require manual review. See the full report for details.
executeSql has 4 params. 4th takes (txn, error), not (error)
To reproduce:
LocalStorageDb
and add documents to each of them, e.g. test1
and test2
removeCollection()
I have fixed the issue in my forked branch:
The lodash package is needed by user-facing (production) code.
FIX: move "lodash" dependency from "devDependencies" to "dependencies" in package.json
you have planned to implement this spatial operator?
Hello,
I would like to request to make minimongo compatible with AMD since this is a separate package from meteor so it is better to have it as AMD module.
Also it let me handle dependencies much more elegent. For example, currently my company going to implement minimongo, but just the LocalStorage DB so it is better to have each module an AMD and we will manually include each module in our gulp build.
Some of the dependencies for minimongo are already available in our source code, and some other are used only by minimongo module like IndexDB, so it could be better to separate them to minimize unused javascript.
Much better and much more elegant.
Thank you!
I want to use Minimongo.
Exposing remoteURL and connectionID on the client seems to be a security problem.
So it's hard to use it as a security issue.
Has anyone solved RemoteDB security problems?
I want you to let me know if you have a good idea ...
Where is the following defined
Line 374 in 87593b1
Remove is defined as remove(id, success, error)
, where as mongo defines remove(<query>, {opts})
... so a query would be nice.
Hint: for anyone trying remove({})
, do a .removeCollection()
then recreate it. or with a filter (remove with query): thecollection.find({filter as usual}).fetch((rows)=>rows.map((row)=>thecollection.remove(row._id)))
I like the work on this, but the GPL license makes it harder to use with commercial projects. Meteor has an MIT license, which works much better for that.
Is there a reason this needs to be GPL or can it switch to Meteor's MIT with the new developers added on?
My business requirements specifies that my mongo docs should be displayed sorted and paged in a table, where their sort order ignores their case. Unfortunately, sorting while ignoring case, is not supported using the current Mongo publication interface.
So currently, my publication must request the complete collection, unsorted, and I must sort the docs locally, then determine which docs I can display for the page.
I am doing that. I copy the whole unsorted minimongo collection into a reactive array (using observe), then sort, then display the correct portion of that instead, and it works, but:
Am I missing something? Is there any way I can hook into mongo/minimongo to specify my more specific publication request, and is there any way I can write something that supports blaze's singledoc display optimization, but when using arrays of docs instead of a collection?
As my number of docs in my collection increases, this is becoming more and more critical.
Any suggestions would be handy. THX
I just noticed when promisifying collection methods that the callback from functions such as "upsert" won't use the node.js callback standard of ( error, result ).
Is there a reason for this? How am supposed to handle errors?
"user_agent": "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; 909) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537"
bowser: {\"name\":\"Windows Phone\",\"windowsphone\":true,\"msie\":true,\"version\":\"11.0\",\"webkit\":true,\"android\":true,\"mobile\":true,\"a\":true}
I am getting module not found errors from Browserify after cloning a fresh repo for development.
The (temporary) fix is:
Tasks need to be run individually (coffee > copy > dist), the 'default' task would allow the dist task to begin running before coffee & copy have completed.
Allow passing an array instead of a single doc
Introduced in d3ddea6... not sure what it's for but it seems like it should have an issue associated with it.
I believe it should be included.
hi,
I have a database on a server and I'm trying to recreate what meteor does; a local db on the browser that syncs bi-directionally with the one on the server.
how do I set this up? I looked at the source code yet I'm unsure what to pass to the url, client and httpClient parameters for the remoteDb constructor. could you provide example code for this scenario? I'm unable to infer this just from reading the docs.
thanks
how to connect it? without it I can't do anything, can anyone help?
I got my mongodb server beside my local web server.
trying out how it works, I ended up with this:
var localDb; var useless_something = minimongo.utils.autoselectLocalDb({namespace: "myDb"}, function(localDb_init) { localDb = localDb_init; }, function() { alert("some error!"); });
Possibly unhandled TypeError: Cannot read property 'transaction' of null
at [object Object].IDBStore.iterate (/Users/mizchi/proj/kobito-shell/shell/node_modules/minimongo/node_modules/idb-wrapper/idbstore.js:1033:38)
at [object Object].IDBStore.query (/Users/mizchi/proj/kobito-shell/shell/node_modules/minimongo/node_modules/idb-wrapper/idbstore.js:1093:19)
at IndexedDb.module.exports.IndexedDb.removeCollection (/Users/mizchi/proj/kobito-shell/shell/node_modules/minimongo/lib/IndexedDb.js:60:23)
This log occurs at atom-shell envrironment but also occur at Chrome.
I tried 2 patterns but both failed. (sorry for coffeescript)
case 1
db = new minimongo.IndexedDb('testdb')
db.addCollection('a')
db.removeCollection('a')
db.addCollection('a')
db.a.find({})
case 2
db = new minimongo.IndexedDb('testdb')
db.addCollection 'a', ->
db.removeCollection 'a', ->
db.addCollection 'a', ->
db.a.find {}
I added setTimeout before find so it works
db = new minimongo.IndexedDb('testdb')
db.addCollection('a')
db.removeCollection('a')
db.addCollection('a')
setTimeout ->
db.a.find({})
, 100
I doubt minimongo lost correct callback of IndexedDb ready.
i noticed in the document that minimongo sends GET to server with optional queries limit
and sort
, but no skip
. does minimongo support skip
?
It looks like they have moved webkitIndexedDB to webkitIDBDatabase. Assuming I am reading your code right. There seems to be a factory pattern too. Not sure the proper way to use the object set yet.
This is reproducible when using the latest Cordova with this plugin.
It would be nice to have a bower / distribution ready version, for easily integration into other projects.
This is in Chrome.
I have minimongo working great for reading/writing to a MemoryDb and writing to an IndexedDb. It can read from the IndexedDb while the current session is active. However, if I refresh the page, in the resources tab of the Chrome debugger I can see all of my data, but after the IndexedDb returns the handle to the database it has no collections. If I create a collection it still can't see the data that was previously written to the collection.
$(document).ready(function() {
new minimongo.IndexedDb({namespace : 'xxxxxx_data'}, function(success) {
indexedDb = success;
call_my_initialize_function_here
}, function(failure) {
});
});
Any thoughts about what I'm doing wrong? Thanks for a great library!
@nickbenes We now support Local Storage, IndexedDb and WebSQL and have an autoselection method. Test coverage is pretty through.
Use cargo to accumulate ops to pass to heavyweight collections.
Test is this:
it "retains changed pending upserts", (done) ->
@db.scratch.upsert { _id: 2, a: 'banana' }, =>
@db.scratch.upsert { _id: 2, a: 'banana2' }, =>
@db.scratch.resolveUpsert { _id: 2, a: 'banana' }, =>
@db.scratch.pendingUpserts (results) =>
assert.equal results.length, 1
assert.equal results[0].a, 'banana2'
done()
But HybridDb uploads as:
@remoteCol.upsert(upsert, () =>
@localCol.resolveUpsert upsert, =>
uploadUpserts(_.rest(upserts), success, error)
which never exercises the code. Even if it did, why would a server change (probably from a merge) require retaining the upsert?
I need update data locally, im using upsert function but the new data is saved in base and the old in doc...
$rootScope.IndexedDb[database].findOne({_id: data['_id']}, {}, function (res) {
if (res === null) {
$rootScope.IndexedDb[database].upsert(data, function () { });
}
else {
if (angular.equals(res, data) == false){
$rootScope.IndexedDb[database].upsert(res, data, function (data_upserted) {
console.log(data_upserted);
});
}
}
});
Yes: http://nparashuram.com/IndexedDBShim/
https://github.com/aaronpowell/db.js
but:
aaronpowell/db.js#55
https://github.com/daleharvey/pouchdb Pretty big.
Very clean:
https://github.com/jensarps/IDBWrapper
Must have automigrate from v1 LocalStorage system and also remain segmented by user. That is, two users must both be able to have active and separated data.
Will make much faster
in hybridDb code we see:
# If caching, get all fields
if options.cacheFind
delete remoteOptions.fields
but sometimes we need to fetch a list from remoteDb, which has loooooooots of items but just includes _id
and name
fields. we need to cache it, so cacheFind
option has to be true. But we don't need the other fields. actually the other fields might be very huge and it's impossible to fetch logs of items all at once.
@grassick would you please consider change this behavior, or at least give a new option to turn this off?
client _id is risk for duplicate, and not compatible with ObjectId about timestamp
since remoteDB support customized httpclient, is it possible to remove the must dependency on jquery, and require jquery only when there's no customized httpclient?
Ugandan internet providers are sometimes causing blank JSON responses to be returned at all for some calls, despite the server sending one. Adding debugging code.
i am wondering if there is somewhere providing a node-express server code which satisfies the remote-deb rest api required by minimongo. feel some lame to build one from scratch... :(
Hi,
Sorry if this isn't a code issue but I'm a bit stuck.
I'm having an issue with removing doc(s) from a database backed by IndexedDB. I've noticed that minimongo is setting the 'state' property to 'removed' in the database, it's not actually being removed.
Thanks in advance!
Hello,
Today I have in the backend an application with mongoDB and I'm building my frontend in PWA, how can I use in frontend the minimongo with synchronization, for my MongoDb backend database?
Do you currently support any update operators, such as $inc, $push, $mul, etc. and is there a plan to support them?
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.