datastore: support kind schema. fixes #85 #86#157
datastore: support kind schema. fixes #85 #86#157stephenplusplus wants to merge 2 commits intogoogleapis:masterfrom
Conversation
|
Probably could have done a better job explaining how this works. The basic idea is, a schema is registered as a hidden "__proto" object on the Kind. It is in the format of an entity proto, without any actual values. When an entity is compared against a kind, the entity is converted to an entity proto, and matched up against the "ghost protocol". |
Can you explain this further? I don't quite understand why this needs to be done and what the purpose of |
|
I'll start this post off the way I started my last one... Probably could have done a better job explaining how this works! There's actually nothing special about {
name: {
metadata: {
type: String,
indexed: false
},
protocol: {
string_value: null
}
},
age: {
metadata: {
type: datastore.int
},
protocol: {
integer_value: null
}
}
}It's currently: {
name: {
type: String,
indexed: false,
__proto: {
string_value: null
}
},
age: {
type: datastore.int,
indexed: false,
__proto: {
integer_value: null
}
}
}The basic idea is to store this "ghost protocol" (it sounds too cool not to call it that) to compare against the later completed protocol, whereby a "protocol" means: an entity in the format the JSON api expects. There are many conversion methods in var schema = {
name: {
type: String,
indexed: false
},
tags: {
type: String,
multi: true
},
favArticles: {
type: 'Key',
multi: true
},
contact: {
type: {
telephone: { type: String },
email: { type: String }
}
}
};...and turn it into an empty (ghost) "protocol". The whole process looks like this:
Hope this helps. Feel free to let me know if you (or anyone else, of course) have any ideas for simplifying the validation. 👍 |
|
Updated to box in the metadata and protocol, as shown in #157 (comment) |
|
@rakyll friendly ping. I know this was going to be M2, but if you have any thoughts on this now, I'm happy to work on them so this makes the cut. Plus, since the change is rather large, the longer we wait, the more likely I'm stuck in rebase sad land. If there's anything I can do a better job of explaining, or you have any questions, let me know. If it makes it, yay! If not, at least we got to remove an outstanding PR :) |
|
Could we keep it open for a while? Datastore has plans for an indexing/schema API. We should cover their needs before we publicize a client supports a schema. |
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 468735472 Source-Link: googleapis/googleapis@cfa1b37 Source-Link: googleapis/googleapis-gen@09b7666 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDliNzY2NjY1NjUxMGY1YjAwYjg5M2YwMDNhMGJhNTc2NmY5ZTI1MCJ9
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 468735472 Source-Link: googleapis/googleapis@cfa1b37 Source-Link: googleapis/googleapis-gen@09b7666 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDliNzY2NjY1NjUxMGY1YjAwYjg5M2YwMDNhMGJhNTc2NmY5ZTI1MCJ9
* updated CHANGELOG.md [ci skip] * updated package.json [ci skip] * updated samples/package.json Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore(main): release 2.0.0 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* Vision beta samples * Vision beta samples * Vision beta samples * Vision beta samples * fixing tests * fixing tests * fixing tests * fixing tests * fixing tests
* fix(package): update @google-cloud/common to version 0.17.0 * Update package locks
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [sinon](https://sinonjs.org/) ([source](https://togithub.com/sinonjs/sinon)) | [`^9.0.0` -> `^10.0.0`](https://renovatebot.com/diffs/npm/sinon/9.2.4/10.0.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>sinonjs/sinon</summary> ### [`v10.0.0`](https://togithub.com/sinonjs/sinon/blob/master/CHANGELOG.md#​1000--2021-03-22) [Compare Source](https://togithub.com/sinonjs/sinon/compare/v9.2.4...v10.0.0) ================== - Upgrade nise to 4.1.0 - Use [@​sinonjs/eslint-config](https://togithub.com/sinonjs/eslint-config)[@​4](https://togithub.com/4) => Adopts ES2017 => Drops support for IE 11, Legacy Edge and legacy Safari </details> --- ### Renovate configuration :date: **Schedule**: "after 9am and before 3pm" (UTC). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-precise-date).
This change just puts `LEVELS` as a static field on the `Logger` object.
Hopefully this is what you had in mind 😊