Comments (9)
Humm.. that's strange. I just double checked the Url.query().run(...) to make sure it was not broke but it works on my side. Can you double check the version of gstore-node (v0.6.1) and google-cloud (v0.38.3)
Try also this for the connection:
var ds = gcloud.datastore();
gstore.connect(ds);
from gstore-node.
From the package.json:
"google-cloud": "0.38.3",
"gstore-node": "0.6.1"
> node -v
v5.1.1
> npm -v
3.5.1
if it will help, I can make an sscce.
from gstore-node.
tested with your minor change:
var ds = gcloud.datastore();
gstore.connect(ds);
It made no difference
from gstore-node.
I am currently working on a demo app still in active development but have a look at how the controller and model are declared. Check main.js (root folder), blog-post.model.js and blog-post.controller.js
https://github.com/sebelga/blog-app-googlecloud/tree/develop
Your initial code seems ok and it's hard to debug without an example.
from gstore-node.
my error is in my config. Instead of passing the file name to the keyFilename property, I was requiring the file and passing the json to it.
{
projectId: 'project_id',
keyFilename: 'file.json'
}
from gstore-node.
on further analysis, this error is related to external files creating & using models without the benefit of the existing datastore instance created on the gstore-object. This is something you'll see a lot in express code. The model in an external file is fine, until you import it in your controller where the gstore object was never declared. Then things start to fall apart.
from gstore-node.
I'm re-opening this as a bug.
The way mongoose works, you don't need a complete connection to create a model. In gstore-node, I need to create the datastore object/connection in my model files so that when I pull in the models elsewhere they work acceptably.
Here's a demo of what I'm talking about. Creating a model before creating a connection is what breaks everything.
var cloudJson = require('./cloud.json');
var gstore = require('gstore-node');
var Schema = gstore.Schema;
var urlSchema = new Schema({
name: { type: 'String', excludeFromIndexes: true },
subdomain: { type: 'String' }
});
var Url = gstore.model('url', urlSchema);
var configGcloud = {
projectId: cloudJson.project_id,
keyFilename: 'cloud.json'
};
var gcloud = require('google-cloud')(configGcloud);
var ds = gcloud.datastore();
gstore.connect(ds);
Url.query().run(function (err, urls) {
if (err) { return console.error(err); }
console.log(urls);
});
from gstore-node.
I see, you're right. I just changed the order of my require (putting the models declaration first) and I reproduced the bug. I will have a look into it. Thanks for reporting!
from gstore-node.
I just released a version that should fix this problem. I am closing this issue, feel free to come back if the problem persists.
from gstore-node.
Related Issues (20)
- query filter on nested property value. HOT 5
- tsc error: Could not find a declaration file for module 'nsql-cache' HOT 3
- could not get data filter by entity key
- Support for @google-cloud/datastore version 5 HOT 2
- Support for custom validators (AJV)
- bulk insert? HOT 2
- Cannot read property 'Symbol(KEY)' when body is null or undefined HOT 1
- Typescript Compile Error HOT 2
- Support for HABTM
- Could not find gstore instance with id "${id}" HOT 2
- How to validate a value agains another property? HOT 1
- Datastore Key type error when using cache HOT 7
- Update method doesn't clear cache HOT 6
- Add Transaction support to `findOne` option HOT 1
- Support filtering for a missing optional property. HOT 1
- New query operators HOT 1
- @google-cloud/datastore version 7 support HOT 1
- could not get data filter by entity key HOT 1
- Migrate Travis CI builds to Circle CI
- Gstore node 7.2.8 TypeError: OptionalDataloader is not a constructor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gstore-node.