New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

orm

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orm - npm Package Compare versions

Comparing version 2.1.30 to 3.0.0

localhost

4

Changelog.md

@@ -1,3 +0,3 @@

### v2.1.30
- Fix paths on windows (#699)
### v3.0.0
- Rename cache -> identityCache & disabled by default (#350, #564, #626, #672, #684, #694, #721)

@@ -4,0 +4,0 @@ ### v2.1.29

@@ -33,3 +33,3 @@ var _ = require('lodash');

var modelOpts = _.extend(
_.pick(opts, 'cache', 'autoSave', 'cascadeRemove', 'hooks', 'methods', 'validations'),
_.pick(opts, 'identityCache', 'autoSave', 'cascadeRemove', 'hooks', 'methods', 'validations'),
{

@@ -36,0 +36,0 @@ id : Object.keys(association.field),

@@ -17,3 +17,3 @@ exports.extend = function (Instance, Model, properties) {

Model.find(conditions, { cache: false }).only(Model.id.concat(property)).first(function (err, item) {
Model.find(conditions, { identityCache: false }).only(Model.id.concat(property)).first(function (err, item) {
return cb(err, item ? item[property] : null);

@@ -31,3 +31,3 @@ });

Model.find(conditions, { cache: false }).only(Model.id.concat(property)).first(function (err, item) {
Model.find(conditions, { identityCache: false }).only(Model.id.concat(property)).first(function (err, item) {
if (err) {

@@ -54,3 +54,3 @@ return cb(err);

Model.find(conditions, { cache: false }).first(function (err, item) {
Model.find(conditions, { identityCache: false }).first(function (err, item) {
if (err) {

@@ -57,0 +57,0 @@ return cb(err);

@@ -301,4 +301,4 @@ var _ = require("lodash");

Singleton.get(uid, {
cache : (options.hasOwnProperty("cache") ? options.cache : opts.cache),
save_check : opts.settings.get("instance.cacheSaveCheck")
identityCache : (options.hasOwnProperty("identityCache") ? options.identityCache : opts.identityCache),
saveCheck : opts.settings.get("instance.identityCacheSaveCheck")
}, function (cb) {

@@ -369,4 +369,4 @@ return createInstance(data[0], {

if (!options.hasOwnProperty("cache")) {
options.cache = opts.cache;
if (!options.hasOwnProperty("identityCache")) {
options.identityCache = opts.identityCache;
}

@@ -401,7 +401,7 @@ if (!options.hasOwnProperty("autoFetchLimit")) {

newInstance : function (data, cb) {
// We need to do the rename before we construct the UID & do the cache lookup
// because the cache is loaded using propertyName rather than fieldName
Utilities.renameDatastoreFieldsToPropertyNames(data, fieldToPropertyMap);
// We need to do the rename before we construct the UID & do the cache lookup
// because the cache is loaded using propertyName rather than fieldName
Utilities.renameDatastoreFieldsToPropertyNames(data, fieldToPropertyMap);
// Construct UID
// Construct UID
var uid = opts.driver.uid + "/" + opts.table + (merge ? "+" + merge.from.table : "");

@@ -412,6 +412,6 @@ for (var i = 0; i < opts.keys.length; i++) {

// Now we can do the cache lookup
// Now we can do the cache lookup
Singleton.get(uid, {
cache : options.cache,
save_check : opts.settings.get("instance.cacheSaveCheck")
identityCache : options.identityCache,
saveCheck : opts.settings.get("instance.identityCacheSaveCheck")
}, function (cb) {

@@ -418,0 +418,0 @@ return createInstance(data, {

@@ -234,3 +234,3 @@ var util = require("util");

indexes : opts.indexes || [],
cache : opts.hasOwnProperty("cache") ? opts.cache : this.settings.get("instance.cache"),
identityCache : opts.hasOwnProperty("identityCache") ? opts.identityCache : this.settings.get("instance.identityCache"),
keys : opts.id,

@@ -237,0 +237,0 @@ autoSave : opts.hasOwnProperty("autoSave") ? opts.autoSave : this.settings.get("instance.autoSave"),

@@ -9,4 +9,4 @@ var _ = require('lodash');

instance : {
cache : true,
cacheSaveCheck : true,
identityCache : false,
identityCacheSaveCheck : true,
autoSave : false,

@@ -13,0 +13,0 @@ autoFetch : false,

@@ -13,7 +13,7 @@ var map = {};

exports.get = function (key, opts, createCb, returnCb) {
if (opts && opts.cache === false) {
if (opts && opts.identityCache === false) {
return createCb(returnCb);
}
if (map.hasOwnProperty(key)) {
if (opts && opts.save_check && typeof map[key].o.saved === "function" && !map[key].o.saved()) {
if (opts && opts.saveCheck && typeof map[key].o.saved === "function" && !map[key].o.saved()) {
// if not saved, don't return it, fetch original from db

@@ -33,3 +33,3 @@ return createCb(returnCb);

o : value,
t : (opts && typeof opts.cache === "number" ? Date.now() + (opts.cache * 1000) : null)
t : (opts && typeof opts.identityCache === "number" ? Date.now() + (opts.identityCache * 1000) : null)
};

@@ -36,0 +36,0 @@ return returnCb(null, map[key].o);

@@ -193,4 +193,4 @@ /// <reference path="sql-query.d.ts" />

static get(key, opts: {
cache?: any;
save_check?: boolean;
identityCache?: any;
saveCheck?: boolean;
}, createCb: Function, returnCb: Function);

@@ -210,4 +210,4 @@ }

instance: {
cache: boolean;
cacheSaveCheck: boolean;
identityCache: boolean;
identityCacheSaveCheck: boolean;
autoSave: boolean;

@@ -214,0 +214,0 @@ autoFetch: boolean;

@@ -15,3 +15,3 @@ {

],
"version" : "2.1.30",
"version" : "3.0.0",
"license" : "MIT",

@@ -49,4 +49,4 @@ "homepage" : "http://dresende.github.io/node-orm2",

"mysql" : "2.9.0",
"pg" : "4.3.0",
"sqlite3" : "3.0.5",
"pg" : "4.4.3",
"sqlite3" : "3.1.0",
"async" : "1.5.0",

@@ -53,0 +53,0 @@ "mocha" : "2.3.3",

@@ -16,5 +16,5 @@ ## Object Relational Mapping

Supported: 0.8, 0.10, 0.12, iojs-1.5
Supported: 0.12 - 4.0 +
Tests are run on [Travis CI](https://travis-ci.org/) for node versions `0.10.x`, `0.12.x` and `iojs-1.5`.
Tests are run on [Travis CI](https://travis-ci.org/)
If you want you can run tests locally:

@@ -74,3 +74,3 @@

// add the table to the database
db.sync(function(err) {
db.sync(function(err) {
if (err) throw err;

@@ -95,3 +95,3 @@

});
});

@@ -284,5 +284,5 @@ });

- `cache` : (default: `true`) Set it to `false` to disable Instance cache ([Singletons](#singleton)) or set a timeout value (in seconds);
- `autoSave` : (default: `false`) Set it to `true` to save an Instance right after changing any property;
- `autoFetch` : (default: `false`) Set it to `true` to fetch associations when fetching an instance from the database;
- `identityCache` : (default: `false`) Set it to `true` to enable identity cache ([Singletons](#singleton)) or set a timeout value (in seconds);
- `autoSave` : (default: `false`) Set it to `true` to save an Instance right after changing any property;
- `autoFetch` : (default: `false`) Set it to `true` to fetch associations when fetching an instance from the database;
- `autoFetchLimit` : (default: `1`) If `autoFetch` is enabled this defines how many hoops (associations of associations)

@@ -521,14 +521,16 @@ you want it to automatically fetch.

### Caching & Integrity
### Identity pattern
Model instances are cached. If multiple different queries will result in the same result, you will
get the same object. If you have other systems that can change your database (or you're developing and need
to make some manual changes) you should remove this feature by disabling cache. This can be done when you're
defining the Model.
You can use the identity pattern (turned off by default). If enabled, multiple different queries will result in the same result - you will
get the same object. If you have other systems that can change your database or you need to call some manual SQL queries,
you shouldn't use this feature. It is also know to cause some problems with complex
autofetch relationships. Use at your own risk.
It can be enabled/disabled per model:
```js
var Person = db.define('person', {
name : String
name : String
}, {
cache : false
identityCache : true
});

@@ -541,7 +543,7 @@ ```

orm.connect('...', function(err, db) {
db.settings.set('instance.cache', false);
db.settings.set('instance.identityCache', true);
});
```
The cache can be configured to expire after a period of time by passing in a number instead of a
The identity cache can be configured to expire after a period of time by passing in a number instead of a
boolean. The number will be considered the cache timeout in seconds (you can use floating point).

@@ -548,0 +550,0 @@

Sorry, the diff of this file is not supported yet

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