express-cassandra
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "express-cassandra", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"dependencies": { | ||
@@ -27,4 +27,16 @@ "apollo-cassandra": "https://github.com/masumsoft/apollo-cassandra/tarball/master", | ||
}, | ||
"keywords": [ | ||
"cassandra", | ||
"orm", | ||
"model", | ||
"db", | ||
"node", | ||
"nodejs", | ||
"express", | ||
"expressjs", | ||
"javascript", | ||
"js" | ||
], | ||
"homepage": "https://github.com/masumsoft/express-cassandra", | ||
"engine": "node >= 0.10.x" | ||
} |
@@ -14,3 +14,3 @@ express-cassandra | ||
## Usage | ||
@@ -87,5 +87,8 @@ ```js | ||
models.instance.Person.find({name: 'jhon'}, function(err, people){ | ||
models.instance.Person.find({name: 'jhon'}, function(err, john){ | ||
if(err) throw err; | ||
console.log('Found ', people); | ||
//Note that returned variable john here is an instance of your model, | ||
//so you can also do john.delete(), john.save() type operations on the instance. | ||
console.log('Found ' + john.name + ' to be ' + john.age + ' years old!'); | ||
}); | ||
@@ -273,4 +276,6 @@ | ||
In the above example it will perform the query `SELECT * FROM person WHERE name='john'` but `find()` allows you to perform even more complex queries on cassandra. You should be aware of how to query cassandra. Every error will be reported to you in the `err` argument, while in `people` you'll find instances of `Person`. If you don't want apollo to cast results to instances of your model you can use the `raw` option as in the following example: | ||
In the above example it will perform the query `SELECT * FROM person WHERE name='john'` but `find()` allows you to perform even more complex queries on cassandra. You should be aware of how to query cassandra. Every error will be reported to you in the `err` argument, while in `people` you'll find instances of `Person`. | ||
If you don't want apollo to cast results to instances of your model you can use the `raw` option as in the following example: | ||
```js | ||
@@ -284,2 +289,12 @@ | ||
You can also select particular columns using the select key in the options object like the following example: | ||
```js | ||
models.instance.Person.find({name: 'John'}, { raw: true, select: ['name','age'] }, function(err, people){ | ||
//people is an array of plain objects with only name and age | ||
}); | ||
``` | ||
### Let's see a complex query | ||
@@ -298,3 +313,3 @@ | ||
models.instance.Person.find(query, function(err, people){ | ||
models.instance.Person.find(query, {raw: true}, function(err, people){ | ||
//people is an array of plain objects | ||
@@ -309,3 +324,3 @@ }); | ||
models.instance.Person.find(query, {allow_filtering: true}, function(err, people){ | ||
models.instance.Person.find(query, {raw:true, allow_filtering: true}, function(err, people){ | ||
//people is an array of plain objects | ||
@@ -452,2 +467,2 @@ }); | ||
All queries except schema definition related queries (i.e. create table etc.) are prepared by default. So you don't | ||
need to set `prepare=true`, the orm takes care of it automatically. | ||
need to set `prepare=true`, the orm takes care of it automatically. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25032
461