Socket
Socket
Sign inDemoInstall

viewmodel

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewmodel - npm Package Compare versions

Comparing version 1.5.22 to 1.6.0

lib/databases/elasticsearch6.js

1

lib/base.js

@@ -16,2 +16,3 @@ 'use strict';

options = options || {};
this.repositoryType = (typeof(options.type) === 'string') ? options.type : null;

@@ -18,0 +19,0 @@ EventEmitter.call(this);

6

lib/databases/mongodb.js

@@ -293,5 +293,7 @@ 'use strict';

if (!this.isConnected || !this.collectionName || !this.indexes) return;
var indexes = (this.repositorySettings && this.repositorySettings.mongodb && this.repositorySettings.mongodb.indexes) ? this.repositorySettings.mongodb.indexes : this.indexes
this.indexes.forEach(function(index) {
if (!this.isConnected || !this.collectionName || !indexes) return;
indexes.forEach(function(index) {
var options;

@@ -298,0 +300,0 @@

@@ -9,2 +9,17 @@ 'use strict';

function exists(toCheck) {
var _exists = require('fs').existsSync || require('path').existsSync;
if (require('fs').accessSync) {
_exists = function (toCheck) {
try {
require('fs').accessSync(toCheck);
return true;
} catch (e) {
return false;
}
};
}
return _exists(toCheck);
}
function getSpecificRepository(options) {

@@ -23,3 +38,2 @@ options = options || {};

var exists = require('fs').existsSync || require('path').existsSync;
if (!exists(dbPath)) {

@@ -26,0 +40,0 @@ var errMsg = 'Implementation for db "' + options.type + '" does not exist!';

@@ -12,3 +12,3 @@ 'use strict';

*/
function ViewModel (attr, repository) {
function ViewModel (attr, repository, version) {
if (!repository) {

@@ -32,2 +32,6 @@ var errMsg = 'Please pass in a valid repository';

// version addition, used by elasticsearch6, null means a new model
if (version !== undefined)
this.version = _.clone(version);
this.actionOnCommit = 'create';

@@ -34,0 +38,0 @@ this.repository = repository;

{
"author": "adrai",
"name": "viewmodel",
"version": "1.5.22",
"version": "1.6.0",
"private": false,

@@ -14,10 +14,10 @@ "main": "index.js",

"dependencies": {
"async": "2.1.4",
"async": "2.5.0",
"dotty": "0.0.2",
"jsondate": "0.0.1",
"lodash": "4.17.2",
"lodash": "4.17.4",
"parent-require": "1.0.0",
"sift": "3.2.6",
"sift": "3.3.12",
"tolerance": "1.0.0",
"uuid": "3.0.0"
"uuid": "3.1.0"
},

@@ -29,4 +29,5 @@ "devDependencies": {

"doqmentdb": ">=0.2.7",
"elasticsearch": "8.x.x",
"eslint": ">=1.0.0",
"elasticsearch": "13.x.x",
"eslint": "^4.3.0",
"eslint-plugin-no-only-tests": "^2.0.0",
"expect.js": ">= 0.1.2",

@@ -33,0 +34,0 @@ "mocha": ">= 1.0.1",

@@ -202,2 +202,3 @@ # Introduction

collectionName: 'dummy',
// like that
indexes: [

@@ -210,2 +211,14 @@ 'profileId',

]
// or like that
repositorySettings : {
mongodb: {
indexes: [ // same as above
'profileId',
// or:
{ profileId: 1 },
// or:
{ index: {profileId: 1}, options: {} }
]
}
}
});

@@ -216,3 +229,58 @@

## Elasticsearch >= 5.X
Use the 'elasticsearch6' type for Elasticsearch versions 5.X and 6.X.
The find queries are not mongoDb compatible as the rest of the implementations due to the uneeded overhead and complexity of converting between both formats.
For find queries with elasticsearch6 use elasticsearch [native elastic Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html);
repository.find( onlyTheQueryClause, otherBodyOptions, callback);
```javascript
repository.find(
{
range : {
age : {
gte : 10,
lte : 20
}
}
),
{
from: 0,
size: 10,
sort: { age: 'asc' }
},
function(error, results) {
});
```
Additionaly for elasticsearch6 the number of shards, number of replicas, the refresh behaivour on index and the mappings on index create can be addtionaly defined to optimize performace.
```javascript
var dummyRepo = repository.extend({
collectionName: 'dummy',
repositorySettings: {
elasticsearch6: {
refresh: 'wait_for', // optional, refresh behaviour on index, default is true ( ie. force index refresh ) https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html
waitForActiveShards: 2 // optional, defaults to 1 ( ie. wait only for primary ) https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#create-index-wait-for-active-shards
index: { // optional applied on index create, https://www.elastic.co/guide/en/elasticsearch/reference/6.x/indices-create-index.html
settings : { // will be merged with the default ones,
number_of_shards: 3, // optional defaults to 1,
number_of_replicas: 1 // optional defaults to 0,
},
mappings : { // optiona will be merged with the default ones,
properties: { // specific properties to not be handled by dynamic mapper
title: {
type: "text"
}
}
}
}
}
}
});
```
# [Release notes](https://github.com/adrai/node-viewmodel/blob/master/releasenotes.md)

@@ -231,2 +299,3 @@

8. elasticsearch ([elasticsearch] (https://github.com/elastic/elasticsearch-js))
9. elasticsearch6 ([elasticsearch] (https://github.com/elastic/elasticsearch-js)) - for Elasticsearch 5.x and 6.x

@@ -257,3 +326,3 @@ ## own db implementation

Copyright (c) 2016 Adriano Raiano
Copyright (c) 2017 Adriano Raiano

@@ -260,0 +329,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -0,1 +1,4 @@

## [v1.6.0](https://github.com/adrai/node-viewmodel/compare/v1.5.22...v1.6.0)
- Elasticsearch 6.X and 5.x implementation [#51](https://github.com/adrai/node-viewmodel/pull/51) thanks to [nanov](https://github.com/nanov) and his company [eCollect](https://github.com/eCollect) which enabled him to work also during working hours
## [v1.5.22](https://github.com/adrai/node-viewmodel/compare/v1.5.20...v1.5.22)

@@ -2,0 +5,0 @@ - fix for new mongodb driver

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