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

Change on query object schema #10

Open
fanchen1988 opened this issue May 16, 2016 · 3 comments
Open

Change on query object schema #10

fanchen1988 opened this issue May 16, 2016 · 3 comments
Assignees

Comments

@fanchen1988
Copy link
Collaborator

fanchen1988 commented May 16, 2016

When I'm implementing the write operation, I encountered some problems and thought that we may need change the query object schema:
0.) Since the write needs the type, query and option sometime, it's very confusing if we still allow type to be placed in the top level of query object. We should just put the type in the query, insert or update, they can specify the type just for query or write.
1.) To make the first level keys of query object to be clear, maybe we should put insert and update into a key called write.

Here is the proposed format after the changes:

{
  "query": {
    "type": "AND",
    "queries": []
  },
  "write": {
    "type": "RAW",
    "update": ""
  },
  "options": {
    "table": "test-table",
    "offset": 100,
    "singleRow": true
  }
}

@chen-factual what do you think about this?

@fanchen1988 fanchen1988 self-assigned this May 16, 2016
@chen-factual
Copy link
Collaborator

Since the write needs the type, query and option sometime, it's very confusing if we still allow type to be placed in the top level of query object. We should just put the type in the query, insert or update, they can specify the type just for query or write.

I see what you're saying. I'd like type as a top level key for simple queries that are query only. So this would be a valid query:

{
  "type": "STANDARD",
  "field": "name",
  "match": "Bob"
}

The type here shouldn't really apply to writes, since values for type are things like AND and OR.

If anything, writes should have their own types, values being INSERT, UPDATE, and RAW. Does that sound reasonable?

@fanchen1988
Copy link
Collaborator Author

@chen-factual I see, so the reason I think keeping type at the top level might be confusing because we may assign different types for query and write(like update), for instance:

{
  "type": "RAW",
  "table": "example-table",
  "query": {
    "field": "field1",
    "match": "baz"
  },
  "upsert": {
    "$set": {
      "field2": "boo",
      "field3": "bar"
    },
    "$setOnInsert": {
      "field1": "baz",
      "field2": "boo",
      "field3": "bar"
    }
  }
}

So in this case, upsert is raw but query is just a standard query. Do you think we need this kind of query object in practice?

@chen-factual
Copy link
Collaborator

I can see a corner use case for it, but in the interest of simplifying things I'd be glad if we enforce RAW to apply to everything, instead of selectively to just one or the other.

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

2 participants