Git Product home page Git Product logo

dexie-mongoify's People

Contributors

darrenpaulwright avatar michaelfakhri avatar yurysolovyov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dexie-mongoify's Issues

$regex Operator Support

Does it support $regex operator? I want to query to see if a string field contains certain substring.

dexie-mongoify not working with latest dexie.js

I've just downloaded the latest dexie.js and the latest dexie-mongoify.min.js and am getting "TypeError: Cannot read property 'push' of undefined"

It appears as though quite a bit has changed in dexie.js lately

Sort tests failing on master

I was just trying to familiarize myself with the codebase to work on the fulltext search item, but after doing a fresh clone of master and doing npm run test, the three $sort operator tests fail.

I tried putting some console logs in the sort operator function, but I can't get the logs to show up. Probably because I don't understand something with Karma. This option didn't lead to the logs showing up:

browserConsoleLogOptions: {
  level: 'log'
},

By the way, would you be open to a PR to update all dependencies, and possibly implement some typings?

image

Nesting operators

What about complex queries with nested $and/$or?

products.find({"$and":[{"$or":[{"pgr_id":{"$eq":6}},{"pgr_id":{"$eq":10}}]},{"name":{"$eq":"test"}}]})

with this kind of query i get the error

Uncaught TypeError: Cannot read property '0' of undefined.

Is this not supported or another syntax required?

how to push to array in a nested object

I am trying to add an object to an existing array which in inside a nested object. The structure looks similar to below

{ 
  Name : 'John',
  age : 33,
  tags : {
     skill: [{
         first: '.NET',
         second: 'JAVA',
         third: [{special1:'sleep'},{special2:'eat'}] 
     }]
  }
}

I have tried many way to push object special3:'run' to skill.third but without success. My last attempt looked something like this

const pathObject = {};
const fullPath = 'result.tags.skill[3].third';
pathObject[fullPath] = {special3:'run'};
db.inspections.update(id, pathObject);

The object is added outside and not inside the array 'third' something like below

{ 
  Name : 'John',
  age : 33,
  tags : {
     skill: [{
         first: '.NET',
         second: 'JAVA',
         third: [{special1:'sleep'},{special2:'eat'}] 
     }]
     skill[3]: {
         third: {special3:'run'}
     }
  }
}

I wish to know if there a way to add to arrays in nested object using dexie-mongoify? Help is appreciated.

find() example problem

The find example:

db.collection('people').find({ age: 30 }).then(function(people) {
    // people 30 years old
});

isn't correct as find() does not return a promise.

This is great + upsert request etc.

@YuriSolovyov I just found mongoify yesterday and have already put it to good use. Many thanks for creating this. The Dexie site needs a list of add-ons, which I'll suggest to them.

One thing I'd like is the ability to use the Mongodb upsert option in update() I've done a crude implementation in my own code which I can show you, if it's of interest.

It would also be good if functions returned the same values as the native mongo driver. For example update returned WriteResult

I'm using MongoDb on the server in a Node.js app and have made a start using Dexie.js in the Browser. mongoify will certainly be a most welcome help in unifying code for my Web app Clibu, http://clibu.com

Could you please write some Wiki content on how mongoify uses indexes. I've had a quick look through the code, but it needs more than that.

We desperately need a unified database api and functionality across Server & Browser, as right now it's a mess. Interestingly there is an job advertisement on the MongoDb site for someone to work on a Browser version of Mongodb!

We have IndexedDB in the Browser which is complex to use, but has a good range of features (secondary indexes, sub-document indexes etc). And Dexie is great.

And for an in-process database on Node.js we really only have leveldb which sadly lacks secondary indexes, sub-document indexes, composite keys etc. The are good wrappers such as levelup, linvodb3 https://github.com/Ivshti/linvodb3 which provides a mongodb api, but currently uses in-memory indexes.

Full text search

Hi All,

Thanks for this great library! I was talking with the folks at textile.io, who are building js-threaddb. It is a local-first database which will sync to the distributed web and currently depends on this library.

IMO, to power serious applications that use the browser for its primary storage mechanism, there needs to be a full-text search capability on the database. I submitted this issue about the topic. Are there any plans to implement full-text search via the $text search operator in dexie-mongoify?

A couple examples of "prior art" on the topic are https://github.com/dfahlander/Dexie.js/blob/master/samples/full-text-search/FullTextSearch.js and https://github.com/yathit/ydn-db-fulltext.

When you have a chance, please let me know if you have any thoughts on this topic and whether you think it makes sense to incorporate with dexie-mongoify. Thanks!

table.update() bugs

@YurySolovyov I have found two problems with table.update() which I don't think are new.

  • Given table`.update( { 'panel': panel }, { 'show': show }, { upsert: true } )
    the value { 'show': show } is not inserted (upserted). This happens when the update spec is a plain ``{ key: value }```. ie. It doesn't use $set etc. My fix is as follows:

Update createObjectForUpsert()

var createObjectForUpsert = function(query, update) {
    ......

    // If no Upsert operators were spec'd we use update as is. ie. i.e. update contains only field and value pairs. NF 2/01/2017
    // ref: https://docs.mongodb.com/manual/reference/method/db.collection.update/#update-parameter
    if ( Object.getOwnPropertyNames( objectFromUpdate ).length === 0 )
        objectFromUpdate = update;

    return assign(objectFromQuery, objectFromUpdate);
};
  • Given table`.update( { 'panel': panel }, { 'show': show }, { upsert: true } )
    the value { 'show': show } is not set if it doesn't already exist. ie. The panel object exists, but the show property doesn't. My fix for this is:
var createPlainPropertyUpdater = function(update, objectKeys) {
    var keys = objectKeys || Object.keys(update);
    return function(item) {
        // Replace entire document.
        // ref: https://docs.mongodb.com/manual/reference/method/db.collection.update/#example-update-replace-fields
        keys.forEach(function(key) {
            // if (has(item, key)) {     // this prevents plain update with values that don't already exist from working. ex. existing doc { a: "1" } -> update { b: "2" } NF 2/01/2017
                item[key] = update[key];
            // }
	        // TODO: item[ key ] which aren't present in update[] need to be removed. Can't be done here as we only have the update spec. Maybe do t in createPlainModifier(). NF 2/01/2017
        });
    };
};

Note that according to the MongoDB docs for collection.update() if no update modifiers are specified the entire document is replaced. At present this is not the case as per my TODO comment above.

I have not exhaustively tested these two fixes, which may possibly break other scenarios so please have a close look at them.

Neville

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.