Skip to content

Switch to verbObject() methods to .object().verb()? #862

Description

@jgeewax

(Using createBucket as an example here)

If I want to "get a hold of a bucket", I can do it in two ways:

gcs.createBucket(name, callback) or gcs.bucket(name). But I have to know what the state of the world is. Get-or-create semantics don't exist, and if they did, it's two different method names, which is a little annoying.

How would we feel about switching to .object()-always syntax, which then has .verb() methods on it? That is, gcs.createBucket(name, callback) would become gcs.bucket(name).create(callback) ? And then for the get-or-create syntax, we could have that as a verb (.getOrCreate())?

So a bunch of examples:

var gcs = ...;
var bucket = gcs.bucket('my-bucket');
bucket.create(function(bucket, err) { ... });
bucket.getOrCreate(function(bucket, err) { ... });
bucket.loadMetadata(function(metadata, err) { ... });

Hypothetically, things like loadMetadata would update the instance of the bucket as well, right? That is, the bucket object in scope of the callback should be identical to the one outside of the scope because we'd store the metadata on this ?

Activity

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions