Giter VIP home page Giter VIP logo

Comments (5)

Viatorus avatar Viatorus commented on May 22, 2024

Thank you for your bug report.

In LokiDB the nested property support has been changed and extended to support binary indices and full-text search indicies by adding getter/setter methods to your documents.

To get your example work, you have to add this to the collection constructor:

nestedProperties: ["key.subkey"]

or to make an alias name:

nestedProperties: [{name: "MyNewSubKey", path: ["key", "subkey"]}]

from lokidb.

cantoine avatar cantoine commented on May 22, 2024

Ah, I missed the nested properties option and that does solve the initial question. One additional question in regard to this does/can nestedProperties work for querying object keys nested in an array? Data would be something like this:

{
  _id: _.uniqueId(),
  arrayObjects: [
    {
       _id: _.uniqueId(),
       key: `value ${ i }`
     }
  ]
}

and the query would be something like { 'arrayObjects.key': 'value 1' }

Thanks!
Chris

from lokidb.

Viatorus avatar Viatorus commented on May 22, 2024

from lokidb.

cantoine avatar cantoine commented on May 22, 2024

That worked perfectly once I figured out how $contains works :-)

Out of curiosity what is the reasoning behind $contains instead of just using the dot notation to find the value? I only ask because finding the value with just dot notation would be more consistent with the mongo api.

Thanks for all of the help!!

from lokidb.

Viatorus avatar Viatorus commented on May 22, 2024

I am glad I could help.

Hmm, that is sad, that it differs from the mongo API...
The problem is, that the dot notation is now resolved while inserting a new document to the collection by adding getter and setter to it and not like LokiJS and MongoDB while performing a query:

https://github.com/techfort/LokiJS/blob/f7acb98a4129845bbd2c9aa23e5ed4a10ee75ce8/src/lokijs.js#L335-L360

The advances are:

  • Only on place you have to handle dot notations
  • The query don`t have to be parsed for dot notations
  • Support for nested binary indices and full-text search (but not for ones inside arrays)
  • Nested property names don`t have to be dots

The disadvances are:

  • If the nested property is inside an array, we return all nested properties as array

Maybe I can fix this disadvances some how...

from lokidb.

Related Issues (20)

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.