Repository navigation
Simple key/value datastore methods #256
Copy link
Copy link
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.
Milestone
Description
Activity
It's definitely possible to build a simple key/value store on top of the Datastore. NDB however is not this. Even then you'd have to define a model with different properties.
Datastore is just a more complicated system than a key/value store. It support querying, consistency guarantees, and a large amount of unstructured data.
If you wanted to build your own wrapper, you could do something very simple like:
function KeyValueDatastore(dataset) { this.dataset = dataset; } // key is a string or int. KeyValueDatastore.get = function(key, value, callback) { this.dataset.get(this.dataset.key(['KeyValue', key]), function(err, entity) { callback(err, 'value' in entity ? entity['value'] : None); } } // key is a string or int. KeyValueDatastore.set = function(key, value, callback) { this.dataset.save({ key : this.dataset.key(['KeyValue', key]), data : { 'value' : value }, function(err, keys) { callback(err); } }); }In terms of handling the key, I just chose a kind to put things into, then using the provided key as either the name or id.
The above could be a good case for a gcloud extension from userland.
var gcloud = require('gcloud')({/*...*/}); var keystore = require('gcloud-keystore'); var dataset = keystore(gcloud.dataset()); dataset.set('company', 'yay'); dataset.get('company', function(err, value) {});
Going to close -- to anyone interested, try out gcloud-keystore!
- addedapi: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
on Feb 2, 2015 - addedtriage meI really want to be triaged.I really want to be triaged.🚨This issue needs some love.This issue needs some love.
on Apr 6, 2020 - added a commit that references this issue
on Sep 27, 2022 - added a commit that references this issue
on Oct 11, 2022 28 remaining items
- added a commit that references this issue
on Mar 5, 2026 - added a commit that references this issue
on Mar 5, 2026 - added a commit that references this issue
on Mar 5, 2026 - added a commit that references this issue
on Mar 18, 2026 - added a commit that references this issue
on Mar 27, 2026 - added a commit that references this issue
on May 5, 2026
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.triage meI really want to be triaged.I really want to be triaged.
Pardon my noob-ish request. As far as I understand, I cannot currently do simple key / value store functionality like due to the inherent complexity of the datastore key objects: