Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about find with key #34

Open
dustinsmith1024 opened this issue Feb 24, 2018 · 0 comments
Open

Question about find with key #34

dustinsmith1024 opened this issue Feb 24, 2018 · 0 comments

Comments

@dustinsmith1024
Copy link

Is there a better way to find something by a name/id? This below works, but seems like the named parameter way should work too.

def find(email) do
    # Works fine, but I want to use the key
    # Diplomat.Query.new("select * from `User` where email_address = @email", %{email: email} )

    "select * from User where __key__ = KEY(User, \"#{email}\")"
    |> Diplomat.Query.new
    |> Diplomat.Query.execute
    |> hd
  end

When I use the names params:

 def find2(email) do
    Diplomat.Query.new("select * from User where __key__ = KEY(User, @email)", %{email: email})
    |> Diplomat.Query.execute
  end

I get:

iex(1)> u = User.find2("dds1024@gmail.com")
{:error,
 %Diplomat.Proto.Status{
   code: 3,
   details: [],
   message: "Encountered \"@email\" at line 1, column 46.\nWas expecting one of:\n    <INTEGER> ...\n    <SINGLE_QUOTE_STRING> ...\n    <DOUBLE_QUOTE_STRING> ...\n    "
 }}
iex(2)>

Semi-new to Google Data Store so I could be missing something simple.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant