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 — Expose something finer than just `.save()` through the datastore abstraction · Issue #384 · googleapis/google-cloud-node

Expose something finer than just .save() through the datastore abstraction #384

New issue
Copy link
New issue
Copy link
Closed
Closed
Expose something finer than just .save() through the datastore abstraction#384
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 Stable

Description

@chilts
chilts
opened on Feb 6, 2015
Issue body actions

One thing I'd like is more features than just .save(). At the moment, I'm inserting a kind=User with name=chilts. However if I were to have another user ask for the name 'chilts', then .save() will say "Oh, the key is complete, so I'll do an update". I would like to make it try an insert and fail because that name already exists (ie. the primary key) ... is that currently possible via your api (from what I can tell it isn't)?

I love how all of the thorny details are abstracted away, but possibly exposing more of the API through here would be awesome. i.e. .insert(), .update() as well as .save(). Sometimes the key logic in .save() isn't needed.

Thanks again for a great library.

Activity

Next
  1. dhermes commented on Feb 6, 2015

    @dhermes
    dhermes
    on Feb 6, 2015
    Contributor
    More actions

    @chilts The relevant verbs are:

    • update - Must exist
    • insert - Must not exist
    • upsert - Can be brand new or exist already
    • insert_auto_id - Incomplete path

    I am also interested in

    1. The demand for this from end users
    2. The solution to this demand
  2. dhermes commented on Feb 6, 2015

    @dhermes
    dhermes
    on Feb 6, 2015
    Contributor
    More actions

    ISTM after a quick scan that the relevant bits of code only use upsert and insert_auto_id (as is done in gcloud-python).

    It just build an accumulator which starts out as

        {
          upsert: [],
          insert_auto_id: []
        }

    and is translated to the relevant protobuf via DatastoreRequest.prototype.makeReq_.

    You could build your own accumulator with update and insert keys and then execute

    DatastoreRequest().makeReq_('commit', req, onCommitCallback);
    
  3. ryanseys commented on Feb 8, 2015

    @ryanseys
    ryanseys
    on Feb 8, 2015
    Contributor
    More actions

    Agreed, we should support insert functionality on its own as it's pretty standard for the "attempting to add new users" use-case that @chilts described above.

  4. ryanseys commented on Feb 8, 2015

    @ryanseys
    ryanseys
    on Feb 8, 2015
    Contributor
    More actions

    @chilts How does #387 fill this need? Basically you'll explicitly set a method for your entity like so:

    var gcloud = require('gcloud');
    var datastore = gcloud.datastore;
    var dataset = datastore.dataset();
    
    dataset.save([
      {
        key: dataset.key({ path: ['User', 'chilts'] }),
        method: 'insert', // force an insert
        data: {
          updateTime: (new Date()).toString()
        }
      }
    ], function(err, result) {
      console.log(err, result);
    });
  5. chilts commented on Feb 8, 2015

    @chilts
    chilts
    on Feb 8, 2015
    Author
    More actions

    Yeah, that would probably work.

    For now (for my current project) I've moved to a different datastore so I'll just keep my eye on how you guys progress over here. Cheers.

  6. ryanseys commented on Feb 8, 2015

    @ryanseys
    ryanseys
    on Feb 8, 2015
    Contributor
    More actions

    Cool please let us know if you have any more ideas how we can make the library better, your feedback is very important :)

  7. stephenplusplus commented on Feb 16, 2015

    @stephenplusplus
    stephenplusplus
    on Feb 16, 2015
    Contributor
    More actions

    This is now merged in and will make it for 0.13.0.

  8. stephenplusplus
    closed this as completedon Feb 16, 2015
  9. jgeewax
    added
    enhancement
    api: datastoreIssues related to the Datastore API.
    on May 14, 2015
  10. jgeewax
    added this to the Datastore Stable milestone on May 14, 2015
  11. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Apr 6, 2020
  12. JustinBeckwith
    assigned
    stephenplusplus
    on Feb 1, 2021
  13. chingor13
    added a commit that references this issue on Aug 22, 2022

    chore: start tracking obsolete files (#384)

    0928813
  14. 48 remaining items

  15. sofisl
    added a commit that references this issue on Feb 5, 2026

    fix: lint (#384)

    5e0e60b
  16. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    chore(deps): update linters (#384)

    64b78e1
  17. sofisl
    added a commit that references this issue on Feb 17, 2026

    fix: lint (#384)

    688bba3
  18. GautamSharda
    added a commit that references this issue on Feb 23, 2026

    chore(deps): update linters (#384)

    5bf2e5a
  19. sofisl
    added a commit that references this issue on Feb 24, 2026

    Removing last bits of asserts (#384)

    6b456c3
  20. GautamSharda
    added a commit that references this issue on Feb 26, 2026

    chore(deps): update linters (#384)

    1318d93
  21. sofisl
    added a commit that references this issue on Feb 26, 2026

    refactor(typescript): perform initial TypeScript conversion (#384)

    29b61f9
  22. GautamSharda
    added 3 commits that reference this issue on Mar 5, 2026

    build: test using @grpc/grpc-js in CI (#384)

    fb518ee

    docs: Add documentation about defaults for publisher (#384)

    79bb0ce

    build: use per-repo publish token (#384)

    88f68a1
  23. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    chore: always nyc report before calling codecov (#384)

    56be243

    chore: always nyc report before calling codecov (#384)

    8c53293
  24. feywind
    added a commit that references this issue on Mar 27, 2026

    Upgrade repo tools and regenerate READMEs. (#384)

    878bc5e
  25. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    chore: always nyc report before calling codecov (#384)

    4bcfa90
  26. thiyaguk09
    added a commit that references this issue on May 5, 2026

    chore: always nyc report before calling codecov (googleapis#384)

    62fb2a3
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 Stable

    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.