Giter Site home page Giter Site logo

Comments (9)

sebelga avatar sebelga commented on May 25, 2024

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.

deltreey avatar deltreey commented on May 25, 2024

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.

deltreey avatar deltreey commented on May 25, 2024

tested with your minor change:

var ds = gcloud.datastore();
gstore.connect(ds);

It made no difference

from gstore-node.

sebelga avatar sebelga commented on May 25, 2024

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.

deltreey avatar deltreey commented on May 25, 2024

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.

deltreey avatar deltreey commented on May 25, 2024

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.

deltreey avatar deltreey commented on May 25, 2024

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.

sebelga avatar sebelga commented on May 25, 2024

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.

sebelga avatar sebelga commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.