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>
* remove unneeded doc links fix * rerun synthtool
🤖 I have created a release \*beep\* \*boop\* --- ## [2.1.0](https://www.github.com/googleapis/nodejs-datacatalog/compare/v2.0.0...v2.1.0) (2020-06-16) ### Features * add order field to TagField and TagTemplateField ([#157](https://www.github.com/googleapis/nodejs-datacatalog/issues/157)) ([70c23c2](https://www.github.com/googleapis/nodejs-datacatalog/commit/70c23c2b609bd24901dc902090e23fbf92b55895)) * move ts target to es2018 from es2016 ([#172](https://www.github.com/googleapis/nodejs-datacatalog/issues/172)) ([e354dde](https://www.github.com/googleapis/nodejs-datacatalog/commit/e354ddeeeedd3e106c50ed579075f23c9d9c5bb5)) * promote library to GA ([#177](https://www.github.com/googleapis/nodejs-datacatalog/issues/177)) ([ac11090](https://www.github.com/googleapis/nodejs-datacatalog/commit/ac110906b723f362024318295e3de6743c905b7e)) ### Bug Fixes * proper fallback option handling ([51df672](https://www.github.com/googleapis/nodejs-datacatalog/commit/51df6721306ab6d2d9bf6919b0f3f432ca85b4ab)) * regenerate unit tests ([#163](https://www.github.com/googleapis/nodejs-datacatalog/issues/163)) ([4593117](https://www.github.com/googleapis/nodejs-datacatalog/commit/45931176d266d364e0508039cf6a4e284ad2923d)) * synth.py clean up for multiple version ([#167](https://www.github.com/googleapis/nodejs-datacatalog/issues/167)) ([c799604](https://www.github.com/googleapis/nodejs-datacatalog/commit/c799604b2d29269006ff39748afb78302ce46ca2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
* Vision beta samples * Vision beta samples * Vision beta samples * Vision beta samples * fixing tests * fixing tests * fixing tests * fixing tests * fixing tests
Hopefully this is what you had in mind 😊