Loopback-datasource-juggler: Create a Cassandra connector

Created on 5 Mar 2014  ยท  42Comments  ยท  Source: loopbackio/loopback-datasource-juggler

Most helpful comment

Hi Cisero,

I created a fork from the original loopback cassandra-connector and I
did a _few
workarounds_
It's far from done and it's not stable. However it's working on my needs.
Take a look here:
https://github.com/brunocarneiro/loopback-connector-cassandra

2016-03-05 15:50 GMT-03:00 Cisero [email protected]:

Any updates on this feature ? Any work arounds in the meantime >?

โ€”
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-192705845
.

All 42 comments

has anyone done some work on this?

This would be great!

+1

Datastax has adopted node-cassandra-cql as their official driver and rebranded it:

https://github.com/datastax/nodejs-driver

+1

ping!

acknld

Rgds,

Nixon.

Date: Sat, 25 Apr 2015 08:04:32 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [loopback-datasource-juggler] Create a Cassandra connector (#84)

ping!

โ€”
Reply to this email directly or view it on GitHub.

+1

+1 (or +infinity)

+1

+1

+1

+1

+1

Bumping up to major as there seems you guys really want this to happen. ;)

+1

+1

I found a Cassandra Connector here:
https://github.com/strongloop-community/loopback-connector-cassandra

Not sure it is working. If so, is there any guide to use it?

By the way +1 to this feature!

+1

Any updates on this feature ? Any work arounds in the meantime >?

Hi Cisero,

I created a fork from the original loopback cassandra-connector and I
did a _few
workarounds_
It's far from done and it's not stable. However it's working on my needs.
Take a look here:
https://github.com/brunocarneiro/loopback-connector-cassandra

2016-03-05 15:50 GMT-03:00 Cisero [email protected]:

Any updates on this feature ? Any work arounds in the meantime >?

โ€”
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-192705845
.

@brunocarneiro Hi bruno! Has you been able to connect to cassandra? I always get an error on juggler "Can't find the property name in undefined." when using the community loopback-connector-cassandra.

When using your forked connector I got the following error

events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at ResultEmitter.emit (events.js:74:15)
at ResultEmitter.onerror (_stream_readable.js:537:12)
at ResultEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:239:10)
at onwrite (_stream_writable.js:257:5)
at WritableState.onwrite (_stream_writable.js:97:5)
at ResultEmitter._write (/opt/loopback-example-access-control/node_modules/loopback-connector-cassandra/node_modules/cassandra-driver/lib/streams.js:449:3)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)

Do tou have any idea ?

Thank you!

Hi @fuzzball1980,

Yes I have been able to connect to Cassandra. I have been using my
connector since December/2015.
It seems to me that it can be a miss configuration in the file
datasources.json.
This is how I use it in development:

//[project-folder]/server/datasources.json
{
"db": {
"host": "localhost",
"name": "db",
"connector": "../../../loopback-connector-cassandra/index",
"keyspace": "mykeyspace"
}
}

2016-03-22 12:55 GMT-03:00 fuzzball1980 [email protected]:

@brunocarneiro https://github.com/brunocarneiro Hi bruno! Has you been
able to connect to cassandra? I always get an error on juggler "Can't find
the property name in undefined." when using the community
loopback-connector-cassandra.

When using your forked connector I got the following error

events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at ResultEmitter.emit (events.js:74:15)
at ResultEmitter.onerror (_stream_readable.js:537:12)
at ResultEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:239:10)
at onwrite (_stream_writable.js:257:5)
at WritableState.onwrite (_stream_writable.js:97:5)
at ResultEmitter._write
(/opt/loopback-example-access-control/node_modules/loopback-connector-cassandra/node_modules/cassandra-driver/lib/streams.js:449:3)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)

Do tou have any idea ?

Thank you!

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199878744

Bruno!

I have been able to connecto but I get a lot of errors when trying to
create the default users/acl model tables.

The errors are like "no viable alternative at input 'NOT' ... in VARCHAR
NOT NULL", seems like for any property with require = true the translation
add a NOT NULL that is not supported on cassandra.

Have you had this problem before?

Thanks a lot!

On Tue, Mar 22, 2016 at 1:17 PM, Bruno Carneiro [email protected]
wrote:

Hi @fuzzball1980,

Yes I have been able to connect to Cassandra. I have been using my
connector since December/2015.
It seems to me that it can be a miss configuration in the file
datasources.json.
This is how I use it in development:

//[project-folder]/server/datasources.json
{
"db": {
"host": "localhost",
"name": "db",
"connector": "../../../loopback-connector-cassandra/index",
"keyspace": "mykeyspace"
}
}

2016-03-22 12:55 GMT-03:00 fuzzball1980 [email protected]:

@brunocarneiro https://github.com/brunocarneiro Hi bruno! Has you been
able to connect to cassandra? I always get an error on juggler "Can't
find
the property name in undefined." when using the community
loopback-connector-cassandra.

When using your forked connector I got the following error

events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at ResultEmitter.emit (events.js:74:15)
at ResultEmitter.onerror (_stream_readable.js:537:12)
at ResultEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:239:10)
at onwrite (_stream_writable.js:257:5)
at WritableState.onwrite (_stream_writable.js:97:5)
at ResultEmitter._write

(/opt/loopback-example-access-control/node_modules/loopback-connector-cassandra/node_modules/cassandra-driver/lib/streams.js:449:3)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)

Do tou have any idea ?

Thank you!

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199878744

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199887306

@fuzzball1980,

DDL generation is not working in this connector. I create my tables
using cqlsh tool.

2016-03-22 13:32 GMT-03:00 fuzzball1980 [email protected]:

Bruno!

I have been able to connecto but I get a lot of errors when trying to
create the default users/acl model tables.

The errors are like "no viable alternative at input 'NOT' ... in VARCHAR
NOT NULL", seems like for any property with require = true the translation
add a NOT NULL that is not supported on cassandra.

Have you had this problem before?

Thanks a lot!

On Tue, Mar 22, 2016 at 1:17 PM, Bruno Carneiro [email protected]
wrote:

Hi @fuzzball1980,

Yes I have been able to connect to Cassandra. I have been using my
connector since December/2015.
It seems to me that it can be a miss configuration in the file
datasources.json.
This is how I use it in development:

//[project-folder]/server/datasources.json
{
"db": {
"host": "localhost",
"name": "db",
"connector": "../../../loopback-connector-cassandra/index",
"keyspace": "mykeyspace"
}
}

2016-03-22 12:55 GMT-03:00 fuzzball1980 [email protected]:

@brunocarneiro https://github.com/brunocarneiro Hi bruno! Has you
been
able to connect to cassandra? I always get an error on juggler "Can't
find
the property name in undefined." when using the community
loopback-connector-cassandra.

When using your forked connector I got the following error

events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at ResultEmitter.emit (events.js:74:15)
at ResultEmitter.onerror (_stream_readable.js:537:12)
at ResultEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:239:10)
at onwrite (_stream_writable.js:257:5)
at WritableState.onwrite (_stream_writable.js:97:5)
at ResultEmitter._write

(/opt/loopback-example-access-control/node_modules/loopback-connector-cassandra/node_modules/cassandra-driver/lib/streams.js:449:3)

at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)

Do tou have any idea ?

Thank you!

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<

https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199878744

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199887306

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199892022

Thank you!!

On Tue, Mar 22, 2016 at 1:58 PM, Bruno Carneiro [email protected]
wrote:

@fuzzball1980,

DDL generation is not working in this connector. I create my tables
using cqlsh tool.

2016-03-22 13:32 GMT-03:00 fuzzball1980 [email protected]:

Bruno!

I have been able to connecto but I get a lot of errors when trying to
create the default users/acl model tables.

The errors are like "no viable alternative at input 'NOT' ... in VARCHAR
NOT NULL", seems like for any property with require = true the
translation
add a NOT NULL that is not supported on cassandra.

Have you had this problem before?

Thanks a lot!

On Tue, Mar 22, 2016 at 1:17 PM, Bruno Carneiro <
[email protected]>
wrote:

Hi @fuzzball1980,

Yes I have been able to connect to Cassandra. I have been using my
connector since December/2015.
It seems to me that it can be a miss configuration in the file
datasources.json.
This is how I use it in development:

//[project-folder]/server/datasources.json
{
"db": {
"host": "localhost",
"name": "db",
"connector": "../../../loopback-connector-cassandra/index",
"keyspace": "mykeyspace"
}
}

2016-03-22 12:55 GMT-03:00 fuzzball1980 [email protected]:

@brunocarneiro https://github.com/brunocarneiro Hi bruno! Has you
been
able to connect to cassandra? I always get an error on juggler "Can't
find
the property name in undefined." when using the community
loopback-connector-cassandra.

When using your forked connector I got the following error

events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at ResultEmitter.emit (events.js:74:15)
at ResultEmitter.onerror (_stream_readable.js:537:12)
at ResultEmitter.emit (events.js:95:17)
at onwriteError (_stream_writable.js:239:10)
at onwrite (_stream_writable.js:257:5)
at WritableState.onwrite (_stream_writable.js:97:5)
at ResultEmitter._write

(/opt/loopback-example-access-control/node_modules/loopback-connector-cassandra/node_modules/cassandra-driver/lib/streams.js:449:3)

at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)

Do tou have any idea ?

Thank you!

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<

https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199878744

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<

https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199887306

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
<
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199892022

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-199905646

Is there any news about this feature?
BTW +1

Yes.. Waiting for this +1

+1

+1

Hi brunocarneiro ,

The first, thanks for solution workarounds from you.
I've been able to connector into cassandra and performed GET, PUT, DELETE but I can't CREATE any models.

My Error is :

Unhandled error for request PATCH /projects?access_token=vdIfG39WkLL0V7jCaCZe8xZLXZ30iBBNqyeDBcqctHMNcwtuhl7LEkbZQnRKpx8K: Error: Some partition key parts are missing: id
at ResponseError.DriverError (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/errors.js:14:19)
at new ResponseError (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/errors.js:51:24)
at FrameReader.readError (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/readers.js:309:13)
at Parser.parseError (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/streams.js:214:57)
at Parser.parseBody (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/streams.js:196:19)
at Parser._transform (/media/killer/My Files/loopback/demoAC/node_modules/cassandra-driver/lib/streams.js:113:10)
at Parser.Transform._read (_stream_transform.js:167:10)
at Parser.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:307:12)
at writeOrBuffer (_stream_writable.js:293:5)
at Parser.Writable.write (_stream_writable.js:220:11)
at Protocol.ondata (_stream_readable.js:555:20)
at emitOne (events.js:96:13)
at Protocol.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Protocol.Readable.push (_stream_readable.js:134:10)

Anyone can help me?

Hi @duongtinh,

It seems to be a Cassandra error. Can you send the query the connector is doing and also your table DDL?

You can get the query debugging this line: https://github.com/brunocarneiro/loopback-connector-cassandra/blob/master/lib/cassandra.js#L163

I saw that you are doing a PATCH request.

_Unhandled error for request PATCH /projects?_

To create new model instances I usually make a POST request. Can you try
making a POST?

2016-10-11 9:55 GMT-03:00 Jack47 [email protected]:

Hi brunocarneiro,

Yes, you right,
This is sql query:

"data" is undefined,
and

INSERT INTO "loopback"."project"("balance","name","ownerid")
VALUES(?,?,?) ;

I think it can not get data from request, have you any idea ?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-252908457,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_6mKnS8DXcXPEqX5sZxDBU_JUbSiq8ks5qy4c2gaJpZM4BnHbU
.

Hi brunocarneiro,

Yes, you right,
My table look like :
{
"id": int,
"balance": int,
"name": "string",
"ownerId": int
}

This is sql query that I debug:

"data" is undefined,
and
INSERT INTO "loopback"."project"("balance","name","ownerid") VALUES(?,?,?) ;

When I create a new row with id
{
"id": 10,
"balance": 220,
"name": "project",
"ownerId": 1
}
=> that show error :
"The project instance is not valid. Details: id can't be set (value: 10).",

but If not include id that show error:

Unhandled error for request PATCH /projects?access_token=vdIfG39WkLL0V7jCaCZe8xZLXZ30iBBNqyeDBcqctHMNcwtuhl7LEkbZQnRKpx8K: Error: Some partition key parts are missing: id
......

have you any idea ?
(sorry my english not good!)

To create new model instances I usually make a POST request. Can you try
making a POST?

Thanks for rely,
I tried but also happen this error.

This error below is related to your loopback model:

"The project instance is not valid. Details: id can't be set (value:
10).",

Can you send you loopback model declaration (json file)?

2016-10-11 10:09 GMT-03:00 Jack47 [email protected]:

To create new model instances I usually make a POST request. Can you try
making a POST?

Thanks for rely,
I tried but also happen this error.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/strongloop/loopback-datasource-juggler/issues/84#issuecomment-252911626,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_6mI0vLvozGvqzgcUK7BUjIErELNP9ks5qy4p6gaJpZM4BnHbU
.

Hi brunocarneiro,
This is my project.json file:

{
"name": "project",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"id": {
"type": "number",
"required": true
},
"balance": {
"type": "number"
},
"name": {
"type": "string"
},
"ownerId": {
"type": "number"
}
},
"validations": [],
"relations": {
"user": {
"type": "belongsTo",
"model": "user",
"foreignKey": "ownerId"
}
},
"acls": [],
"methods": {}
}

Seems it's correct.
Just to be sure, I would use:

"id": {
"type": "number",
"required": true,
"id": true
},
...

Oh...I just saw now. Please remove the relation and give a try.

Hi brunocarneiro,

Just to be sure, I would use:

"id": {
"type": "number",
"required": true,
"id": true
},

I've been able to CREATE successful. Thanks for your support.

Beside, I also have a problem with models generated when create an application loopback.
Example: User, Role...
When I try to create tables following structure User, Roel... models using cqlsh tool then using API to Create new User or Role, but I always met error:

{
  "error": {
    "statusCode": 422,
    "name": "ValidationError",
    "message": "The `User` instance is not valid. Details: `email` is invalid (value: \"[email protected]\"); `username` is invalid (value: \"aaaaaa\").",
    "details": {
      "context": "User",
      "codes": {
        "email": [
          "uniqueness.Error: All host(s) tried for query failed. First host tried, 192.168.173.129:9042: Error: connect EHOSTUNREACH 192.168.173.129:9042. See innerErrors."
        ],
        "username": [
          "uniqueness.Error: All host(s) tried for query failed. First host tried, 192.168.173.129:9042: Error: connect EHOSTUNREACH 192.168.173.129:9042. See innerErrors."
        ]
      },
      "messages": {
        "email": [
          "is invalid"
        ],
        "username": [
          "is invalid"
        ]
      }
    }
  }
}

My model User:

{
  "id": 10,
  "realm": "aaaa",
  "username": "aaaaaa",
  "password": "123456",
  "email": "[email protected]"
}

But I can GET or DELETE;

Have you any idea?

Hi all,

How are you?
I've issue when filter hasMany in loopback and cassandra:

Model Customer:

{
  "name": "customer",
  "base": "PersistedModel",
 ...
  "properties": {
    "id": {
      "type": "number",
      "id": true,
      "required": true
    },
    "username": {
      "type": "string",
      "required": true
    },
    "password": {
      "type": "string",
      "required": true
    }
  },
  "validations": [],
  "relations": {
    "projects": {
      "type": "hasMany",
      "model": "project",
      "foreignKey": "ownerId"
    }
  },
  "acls":{},
  "methods": {}
}

Model Project:

{
  "name": "project",
  "base": "PersistedModel",
 ...
  },
  "properties": {
    ...
    "ownerId": {
      "type": "number"
    }
  },
  "validations": [],
  "relations": {
    "customers": {
      "type": "belongsTo",
      "model": "customer",
      "foreignKey": "ownerId"
    }
  },
  "acls": {},
  "methods": {}
}

In Project API I can get customer belongTo project but when I get all projects of a customer then it show error:

Error: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING

Anyone can help me?

Closing this, because we now have loopback-connector-cassandra (https://github.com/strongloop/loopback-connector-cassandra).

Was this page helpful?
0 / 5 - 0 ratings