GeezerVison is showing github.com — Why is datastore initialized differently than the other libraries? · Issue #593 · googleapis/google-cloud-node
Why is datastore initialized differently than the other libraries? #593DescriptionSee here for what I'm talking about. Seems that once gcloud is initialized, datastore cannot be initialized with different options. I think this is because we delegated it to the dataset object instead but that just is kinda messy. Would it be worth it to change this to be consistent with the other APIs?
Current way:
var gcloud = require('gcloud')(options);
var datastore = gcloud.datastore;
var dataset = datastore.dataset(newOptions);
Proposed way:
var gcloud = require('gcloud')(options);
var datastore = gcloud.datastore(newOptions);
var dataset = datastore.dataset();
ADDITIONAL CRAZY IDEA: What if we just eliminated the dataset altogether? Something like:
var gcloud = require('gcloud')(options);
var datastore = gcloud.datastore(newOptions);
var key = datastore.key('Company');
datastore.save(key, { data: { hello: 'world' } }, callback);
Anything preventing us from doing this? Activitystephenplusplus commented on May 12, 2015 I would really like to do the last one. @rakyll said to anticipate more things added to Datastore, which was why we couldn't do it. jgeewax commented on May 12, 2015 I'm down for:
var gcloud = require('gcloud')(options);
var datastore = gcloud.datastore(newOptions);
var dataset = datastore.dataset('name of the dataset' /* optional */);
var key = datastore.key('Company');
datastore.save(key, { data: { hello: 'world' } }, callback);
The reason we can't kill data set is that we are in the process of adding the ability to have multiple datasets (we'll probably call them databases) per project, so datastore.save() is a misleading concept...
But I still think we need to allow you to configure stuff at the datastore level... ? right? ryanseys commented on May 12, 2015 ContributorAuthor More actions Oh, as far as I understand right now we have no concept of a name of a dataset, right? In that case I like my first new proposal where it will just take no options for the time being until this multi-dataset functionality rolls around. This would be a breaking change. jgeewax commented on May 12, 2015 datastore.dataset() should always still work, and default to the ID of the project. In the future, we need a way of passing in a name of a dataset (datastore.dataset('name')).
Don't think this should be a breaking change, right? ryanseys commented on May 12, 2015 ContributorAuthor More actions It would be breaking because gcloud.datastore will now be a function that needs to be called with options. datastore.dataset will no longer accept these options. And it doesn't make sense to have it in both places. jgeewax commented on May 12, 2015 Gotcha - we couldn't make it work with and without the parens? (gcloud.datastore == gcloud.datastore()) ? ryanseys commented on May 12, 2015 ContributorAuthor More actions Maybe but if we're in the business of breaking things with the moving of options from dataset to datastore then we should just break it. Also this is much easier to do pre-1.0 stephenplusplus commented on Jun 30, 2015 Just want to make sure this is correct:
// uses dataset-id-1:
var gcloud = require('gcloud')({ projectId: 'dataset-id-1' });
gcloud.datastore.dataset();
// uses dataset-id-2:
var gcloud = require('gcloud')({ projectId: 'dataset-id-1' });
var datastore = gcloud.datastore({ projectId: 'dataset-id-2' });
datastore.dataset();
// uses dataset-id-3:
var gcloud = require('gcloud')({ projectId: 'dataset-id-1' });
var datastore = gcloud.datastore({ projectId: 'dataset-id-2' });
datastore.dataset('dataset-id-3'); // the projectId given above is useless.stephenplusplus commented on Sep 4, 2015 callmehiphop commented on Sep 4, 2015 I don't believe so, I think it would simplify the api object creation though. stephenplusplus commented on Nov 25, 2015 This is going to be not-a-thing when datastore v1beta3 is released (see #897). The dataset concept is gone and there is only a "datastore" per project.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|