3 ms·
This looks incredible. I've been wanting a clean way to select multiple random objects from my Parse db. Until now, this was the best answer: https://parse.com/
by adelevie 14y ago
This looks incredible. I've been wanting a clean way to select multiple random objects from my Parse db. Until now, this was the best answer: https://parse.com/questions/random-search-its-possibile https://parse.com/questions/random-search-its-possibile.
Also, it seems possible to combine this with IronWorker. You could create a worker in Ruby, then in the Parse Cloud Code, call that worker's endpoint. Something like this (rough sketch):
worker.rb:
require "some_ruby_email_gem"
cgi_parsed = CGI::parse(payload)
email = payload["email"]
SomeRubyEmailGem.send(email, "Welcome, #{email}!")
upload.rb:
require 'iron_worker_ng'
client = IronWorkerNG::Client.new(:token => config['iw']['token'], :project_id => config['iw']['project_id'])
code = IronWorkerNG::Code::Ruby.new
code.merge_worker 'worker.rb'
code.merge_gem "some_ruby_email_gem"
client.codes.create(code)
url = "https://worker-aws-us-east-1.iron.io/2/projects/#{config['iw']['project_id']}/tasks/webhook?code_name=#{code.name}&oauth=#{config['iw']['token']}"
puts "Add this url to to your Parse Cloud Code:"
puts url
Parse Cloud Code:
Parse.Cloud.define("welcome, function(request, response) {
var user = request.object.get("user");
var url = "https://worker-aws-us-east-1.iron.io/2..." // the url from upload.rb
http.open("POST", url+"?email="+user.email, true);
});
EDIT: HTTP requests to 3rd parties within Cloud Code are not possible yet, but Parse will add the feature soon. (http://twitter.com/ParseIt/status/245584646686003200 http://twitter.com/ParseIt/status/245584646686003200)