GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Simple key/value datastore methods · Issue #256 · googleapis/google-cloud-node

Simple key/value datastore methods #256

New issue
Copy link
New issue
Copy link
Closed
Closed
Simple key/value datastore methods#256
Copy link
Assignees
stephenplusplus
Labels
🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.
Milestone
Datastore Future

Description

@ryanseys
ryanseys
opened on Oct 13, 2014
Issue body actions

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:

var key = "hello"; // string or number
var value = "world"; // string or number

datastore.set(key, value, function(err) {
  if(!err) {
    // success;
  } 
});

datastore.get("hello", function(err, val) {
  val; // "world"
});

Activity

Next
  1. ryanseys commented on Oct 13, 2014

    @ryanseys
    ryanseys
    on Oct 13, 2014
    ContributorAuthor
    More actions

    @pcostell

  2. beriberikix commented on Oct 13, 2014

    @beriberikix
    beriberikix
    on Oct 13, 2014
    Contributor
    More actions

    @pcostell @jgeewax is this why an NDB layer would be useful?

  3. pcostell commented on Oct 13, 2014

    @pcostell
    pcostell
    on Oct 13, 2014
    Contributor
    More actions

    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.

  4. stephenplusplus commented on Oct 14, 2014

    @stephenplusplus
    stephenplusplus
    on Oct 14, 2014
    Contributor
    More actions

    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) {});
  5. stephenplusplus commented on Oct 14, 2014

    @stephenplusplus
    stephenplusplus
    on Oct 14, 2014
    Contributor
    More actions

    https://github.com/stephenplusplus/gcloud-keystore 👍

  6. stephenplusplus commented on Oct 16, 2014

    @stephenplusplus
    stephenplusplus
    on Oct 16, 2014
    Contributor
    More actions

    Going to close -- to anyone interested, try out gcloud-keystore!

  7. stephenplusplus
    closed this as completedon Oct 16, 2014
  8. jgeewax
    added
    api: datastoreIssues related to the Datastore API.
    enhancement
    on Feb 2, 2015
  9. jgeewax
    added this to the Datastore Future milestone on Feb 2, 2015
  10. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Apr 6, 2020
  11. JustinBeckwith
    assigned
    stephenplusplus
    on Feb 1, 2021
  12. sofisl
    added a commit that references this issue on Sep 27, 2022

    docs: update return type in jsdoc for Buffers (#256)

    b4eba0f
  13. sofisl
    added a commit that references this issue on Oct 11, 2022

    feat: support apiEndpoint override in client constructor (#256)

    5e9bc5a
  14. 28 remaining items

  15. sofisl
    added 3 commits that reference this issue on Feb 24, 2026

    Allowing 101 listeners (#256)

    f22f001

    fix: Fix client pooling for long-lived listens (#614)

    9eb55fa

    refactor: update auth library, common-grpc (#256)

    5396086
  16. codyoss
    added a commit that references this issue on Mar 5, 2026

    chore(nodejs): remove api-extractor dependencies (#256)

    8a98d54
  17. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    chores(build): run codecov on continuous builds (#256)

    b60fa0a
  18. sofisl
    added a commit that references this issue on Mar 5, 2026

    chore(deps): update dependency sinon to v9 (#256)

    e86088a
  19. codyoss
    added 2 commits that reference this issue on Mar 9, 2026

    docs: add instructions for authenticating for system tests (#256)

    7560aa2

    docs: add instructions for authenticating for system tests (#256)

    e6f2159
  20. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    feat: Add optional delay when calling nack() (#255) (#256)

    ff52f3c

    Don't publish sourcemaps (#256)

    774bc0a
  21. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    chore: update sample lockfiles (googleapis#256)

    e1869ef
  22. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    chore: add node templates to synth.py (#256)

    b9fee7c

    chore: add node templates to synth.py (#256)

    1a9da7c
  23. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    chore: add node templates to synth.py (#256)

    55b5b24
  24. thiyaguk09
    added a commit that references this issue on May 5, 2026

    chore: add node templates to synth.py (googleapis#256)

    cec2e64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

Labels

🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    • Datastore FutureNo due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.