Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
JavaScript ORM for RethinkDB.
Note: Alpha release
Install:
npm install thinky
Use
var thinky = require('thinky');
thinky.connect({});
// Create a model
var Cat = thinky.createModel('Cat', {name: String});
// Create custom methods
Cat.define('hello', function() { console.log("Hello, I'm "+this.name) });
// Create a new object
kitty = new Cat({name: 'Kitty'});
kitty.hello(); // Log "Hello, I'm Kitty
kitty.save(function(err, result) {
if (err) throw err;
console.log("Kitty has been saved in the database");
})
Note: Work in progress.
Thinky.connect( options )
options (object): object with the fields
Note: The behavior of enforce may change. Since there are more than two cases
Thinky.getOptions()
Returns all the options previously set.
Thinky.getOption( optionName )
Returns the value for optionName. Possible values:
- host: RethinkDB host
- port: RethinkDB port for client
- db: default database
- poolMax: The maximum number of connections in the pool
- poolMin: The minimum number of connections in the pool
- enforce: Boolean that represent if the schemas should be enforced or not
Thinky.setOptions( options )
Overwrite the options defined in options.
The argument options is an object that can have the following fields - host: RethinkDB host (default "localhost") - port: RethinkDB port for client (default to 28015) - db: default database (default to "test") - poolMax: The maximum number of connections in the pool (default to 10) - poolMin: The minimum number of connections in the pool (default to 1) Setting a value to null will delete the value.
Note: Almost useless for now since we don't recreate/update the pool
Thinky.disconnect()
Close all the connections.
Thinky.createModel( name, schema, settings ) Create a new model
Valid schema can be:
{ name: String }
{ name: { type: String } } // {name: "Kitty"} or { name: { type: "Kitty" } }?
{ name: { type: String, default: value/function }
{ name: { type: [String, Number, ...] }
{ age: { type: Number, min: ..., max: ...} }
{ comments: { type: Array, min: ..., max: ...} }
{ arrayOfStrings: [ String ] }
{ arrayOfStrings: [ String, maxLength, minLength ] }
Coming soon: default with object and arrays.
Model.compile( name, schema, settings, thinky )
Internal method
Model.createBasedOnSchema( result, doc, originalDoc, enforce, prefix, schema )
Internal method
Model.checkType( result, doc, originalDoc, schema, key, type, typeOf, prefix, enforce )
Internal method
Model.define( key, method )
Define a method on the model that can be called by any instances of the model.
Model.setSchema( schema )
Change the schema -- Not tested (I think)
Model.getSettings( )
Return the settings of the model.
Model.getDocument( )
Return the document.
Model.getPrimaryKey( )
Return the primary key
Model.save( callback, overwrite )
Save the object in the database. Thinky will call insert or update depending on whether how the object was created.
overwrite: not implemented yet
Model.get( id or [ids], callback )
Retrieve one or more documents
Model.filter( filterFunction )
Retrieve document based on the filter.
Model.count( )
Return the number of element in the table of your model.
Model.mapReduce( filterFunction )
Not yet implemented
Document.getDocument( )
Internal method?
Document.getModel( )
Return the model of the document.
Document.getSettings( )
Document.define( name, method )
Document.replace( newDoc ) Not implemented yet
All method of EventEmitter are available on Document. They do not pollute the document itself.
When you create a new object from a model, the object has the following chain of prototypes object -> DocumentObject -> Document -> model
Run the tests
mocha
You are welcome to do a pull request.
Author: Michel Tu -- orphee@gmail.com -- www.justonepixel.com
Copyright (c) 2013 Michel Tu orphee@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
RethinkDB ORM for Node.js
The npm package thinky receives a total of 935 weekly downloads. As such, thinky popularity was classified as not popular.
We found that thinky demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.