Giter Club home page Giter Club logo

Comments (11)

coffeemug avatar coffeemug commented on June 22, 2024

@sojin this is because some of the documents don't have age as an attribute and rethink is strict about errors (if an attribute is missing and you try to use it, it'll throw an error). We'll make an api much nicer to deal with cases like this, but in the meantime you can try this:

db('python_tutorial').table('heroes').filter(lambda row: row.contains('age') & (r['age'] ==26)).run()

from rethinkdb.

sojin avatar sojin commented on June 22, 2024

Thanks, that did the trick.We are evaluating Rethink as an alternative for MongoDB, still trying to get my head around the docs. :)

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

Great, all questions are welcome (irc, here, or google groups)!

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

Ok, we need to add the following two enhacements:

# Defaults in attr access
table('foo').filter(r['bar', 0] == 1).run()

# Defaults command on streams
table('foo').defaults({ 'bar': 0 }).filter(r['bar'] == 1).run()

Moving to backlog, will address when some pressing initial issues are worked out.

from rethinkdb.

nviennot avatar nviennot commented on June 22, 2024

Can we have something to also have every attribute to default to nil? (I don't want to spend my time specifying the name of each attribute I'm going to use in the filter)

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

I reopened #183, so we may try to find a different approach to this problem (although adding a modifier to evaluate missing attributes to nil is one option).

from rethinkdb.

craigyk avatar craigyk commented on June 22, 2024

I think a default command would be a good thing, though it shouldn't be used to address #183. I think there should be a ni | undefined value that behaves a lot like NaN and causes the row to be removed by default.

from rethinkdb.

jdoliner avatar jdoliner commented on June 22, 2024

The discussion if this has become a bit fractures but I think that were all
in agreement (although we haven't explicitly said it) that filter and
similar commands will be looking for Nothing and dropping those rows.
On Feb 23, 2013 6:27 PM, "Craig" [email protected] wrote:

I think a default command would be a good thing, though it shouldn't be
used to address #183 #183.
I think there should be a ni | undefined value that behaves a lot
like NaN and causes the row to be removed by default.


Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-14002217.

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

This may or may not be a dup of #183, depending on how we look at it. I'll consider this shortly.

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

FYI -- defaults on streams could be implemented as a special kind of merge, which would require a new merge function to do right, which would require a map over objects to do right (of course we could also just do it, and fill in the architectural foundation later). Anyway, this is all discussed on google groups, and the link to the discussion is in the body of the issue #186. (Just so we don't lose track of the fact that these things are related).

from rethinkdb.

coffeemug avatar coffeemug commented on June 22, 2024

This issue has now been subsumed by #570. Closing.

from rethinkdb.

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.