Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property query filtering snippet. #47

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,356 changes: 1,356 additions & 0 deletions datastore/concepts.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"dependencies": {
"async": "^1.5.0",
"gcloud": "^0.25.0"
"gcloud": "stephenplusplus/gcloud-node#spp--datastore-v1beta3"
}
}
2 changes: 1 addition & 1 deletion datastore/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (keyFile) {
options.keyFilename = keyFile;
}

var datastore = gcloud.datastore.dataset(options);
var datastore = gcloud.datastore(options);
// [END build_service]

/*
Expand Down
129 changes: 129 additions & 0 deletions test/datastore/entity.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright 2015, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var testUtil = require('./util.js');

var Entity = require('../../datastore/concepts').Entity;
var entity;

describe('datastore/concepts/entity', function () {
before(function() {
var projectId = process.env.TEST_PROJECT_ID || 'nodejs-docs-samples';
entity = new Entity(projectId);
});

after(function(done) {
var datastore = entity.datastore;
var query = datastore.createQuery('Task');

testUtil.deleteEntities(datastore, query, done);
});

describe('incomplete key', function() {
it('saves with an incomplete key', function(done) {
entity.testIncompleteKey(done);
});
});

describe('testNamedKey', function() {
it('saves with a named key', function(done) {
entity.testNamedKey(done);
});
});

describe('testKeyWithParent', function() {
it('saves a key with a parent', function(done) {
entity.testKeyWithParent(done);
});
});

describe('testKeyWithMultiLevelParent', function() {
it('saves a key with multiple parents', function(done) {
entity.testKeyWithMultiLevelParent(done);
});
});

describe('testEntityWithParent', function() {
it('saves an entity with a parent', function(done) {
entity.testEntityWithParent(done);
});
});

describe('testProperties', function() {
it('saves an entity with properties', function(done) {
entity.testProperties(done);
});
});

describe('testArrayValue', function() {
it('saves an entity with arrays', function(done) {
entity.testArrayValue(done);
});
});

describe('testBasicEntity', function() {
it('saves a basic entity', function(done) {
entity.testBasicEntity(done);
});
});

describe('testUpsert', function() {
it('saves with an upsert', function(done) {
entity.testUpsert(done);
});
});

describe('testInsert', function() {
it('saves with an insert', function(done) {
entity.testInsert(done);
});
});

describe('testLookup', function() {
it('performs a lookup', function(done) {
entity.testLookup(done);
});
});

describe('testUpdate', function() {
it('saves with an update', function(done) {
entity.testUpdate(done);
});
});

describe('testDelete', function() {
it('deletes an entity', function(done) {
entity.testDelete(done);
});
});

describe('testBatchUpsert', function() {
it('performs a batch upsert', function(done) {
entity.testBatchUpsert(done);
});
});

describe('testBatchLookup', function() {
it('performs a batch lookup', function(done) {
entity.testBatchLookup(done);
});
});

describe('testBatchDelete', function() {
it('performs a batch delete', function(done) {
entity.testBatchDelete(done);
});
});
});
37 changes: 37 additions & 0 deletions test/datastore/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
indexes:
- kind: Task
properties:
- name: done
- name: priority
direction: desc
- kind: Task
properties:
- name: priority
- name: percent_complete
- kind: Task
properties:
- name: type
- name: priority
- kind: Task
properties:
- name: priority
- name: created
- kind: Task
properties:
- name: done
- name: created
- kind: Task
properties:
- name: type
- name: priority
direction: desc
- kind: Task
properties:
- name: type
- name: created
- kind: Task
properties:
- name: priority
direction: desc
- name: created

47 changes: 47 additions & 0 deletions test/datastore/indexes.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2015, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var testUtil = require('./util.js');

var Index = require('../../datastore/concepts').Index;
var index;

describe('datastore/concepts/indexes', function () {
before(function() {
var projectId = process.env.TEST_PROJECT_ID || 'nodejs-docs-samples';
index = new Index(projectId);
});

after(function(done) {
var datastore = index.datastore;
var query = datastore.createQuery('Task');

testUtil.deleteEntities(datastore, query, done);
});

describe('unindexed properties', function() {
it('performs a query with a filter on an unindexed property',
function(done) {
index.testUnindexedPropertyQuery(done);
}
);
});

describe('exploding properties', function() {
it('inserts arrays of data', function(done) {
index.testExplodingProperties(done);
});
});
});
63 changes: 63 additions & 0 deletions test/datastore/metadata.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2015, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var testUtil = require('./util.js');

var Metadata = require('../../datastore/concepts').Metadata;
var metadata;

describe('datastore/concepts/metadata', function () {
before(function() {
var projectId = process.env.TEST_PROJECT_ID || 'nodejs-docs-samples';
metadata = new Metadata(projectId);
});

after(function(done) {
var datastore = metadata.datastore;
var query = datastore.createQuery('Task');

testUtil.deleteEntities(datastore, query, done);
});

describe('namespace query', function() {
it('performs a namespace query', function(done) {
metadata.testNamespaceRunQuery(done);
});
});

describe('kinds query', function() {
it('performs a kind query', function(done) {
metadata.testKindRunQuery(done);
});
});

describe('property query', function() {
it('performs a property query', function(done) {
metadata.testPropertyRunQuery(done);
});
});

describe('property by kind query', function() {
it('performs a property by kind query', function(done) {
metadata.testPropertyByKindRunQuery(done);
});
});

describe('property filtering query', function() {
it('performs a filtered property query', function(done) {
metadata.testPropertyFilteringRunQuery(done);
});
});
});
Loading