Socket
Socket
Sign inDemoInstall

express-cassandra

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-cassandra - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

test/models/SimpleModel.js

9

lib/orm/base_model.js

@@ -1580,2 +1580,11 @@ var util = require('util'),

BaseModel.prototype.toJSON = function toJSON() {
var object = {};
var schema = this.constructor._properties.schema;
for(var field in schema.fields) {
object[field] = this[field];
}
return object;
};
module.exports = BaseModel;

2

package.json
{
"name": "express-cassandra",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {

@@ -5,0 +5,0 @@ "async": "^1.0.0",

@@ -821,2 +821,4 @@ [![Build Status](https://travis-ci.org/masumsoft/express-cassandra.svg)](https://travis-ci.org/masumsoft/express-cassandra)

Note that, result objects here in callback will be model instances. So you may do operations like `john.save`, `john.delete` etc on the result object directly. If you want to extract the raw javascript object values from a model instance, you may use the toJSON method like `john.toJSON()`.
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`.

@@ -823,0 +825,0 @@

@@ -922,2 +922,33 @@ var models = require('../index');

describe('#toJSON returns object with model fields only',function(){
it('should return the object for new model instance', function() {
var simple = new models.instance.Simple({foo:"bar"});
simple.toJSON().should.deep.eq({
foo: "bar",
bar: "baz"
});
JSON.stringify(simple).should.eq('{"foo":"bar","bar":"baz"}');
should.exist(simple._validators);
});
it('should return the object for fetched model', function(done) {
var simple = new models.instance.Simple({foo:"bar"});
simple.save(function save(err){
if(err) throw err;
models.instance.Simple.findOne({}, function findOne(err, simpleModel){
simpleModel.toJSON().should.deep.eq({
foo: "bar",
bar: "baz"
});
JSON.stringify(simpleModel).should.eq('{"foo":"bar","bar":"baz"}');
should.exist(simpleModel._validators);
simpleModel.delete(function del(err){
if(err) throw err;
done();
});
});
});
});
});
describe('#close cassandra connection',function(){

@@ -924,0 +955,0 @@ it('should close connection to cassandra without errors', function(done) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc