Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3947

Question: How to run native Javascript code on MongoDB?

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Hi, I'd like to be able to natively execute Javascript code on MongoDB via Mongoid / Moped

      Here's a simplified example of what I'd like to do:

      var cursor = #{ criteria.query.xxx ? }
      if (cursor.count < 100) { cursor } else { [] }
      
      • criteria.query.xxx represents the serialized Javascript string for my Mongoid query criteria which I've passed-in via string interpolation, i.e {{db.customers.find( {"name": "bob"}

        )}}.

      • The result should be serialized into Customer objects in Ruby.

      Is this possible to do? (I'm using Mongoid 3 at the moment)

            Assignee:
            Unassigned Unassigned
            Reporter:
            johnnyshields Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: