Socket
Socket
Sign inDemoInstall

castor-load-custom

Package Overview
Dependencies
66
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.0 to 1.4.0

32

index.js

@@ -80,3 +80,3 @@ /*jshint node:true, laxcomma:true*/

options = options || {};
options.fieldname = options.fieldname ? options.fieldname : 'userfields';
options.fieldname = options.fieldname ? options.fieldname : 'documentFields';
options.schema = options.schema ? options.schema : {};

@@ -185,9 +185,31 @@

// Truncate resulting strings, to allow the indexing by Mongo
// (Mongo 2.6 does not insert the document if any indexing does not work)
if (typeof values[key] === 'string') {
values[key] = S(values[key]).truncate(250).toString();
//
// .mapping
//
if (options.schema[key].mapping) {
if ((typeof values[key] === 'string' || typeof values[key] === 'number') && options.schema[key].mapping[values[key]]) {
values[key] = options.schema[key].mapping[values[key]];
}
else if (Array.isArray(values[key])) {
values[key] = values[key].map(function(i) {
if ((typeof i === 'string' || typeof values[key] === 'number') && options.schema[key].mapping[i]) {
values[key] = options.schema[key].mapping[i];
}
});
}
}
//
// .noindex
//
if (options.schema[key].noindex !== true) {
if (typeof values[key] === 'string') {
// Truncate resulting strings, to allow the indexing by Mongo
// (Mongo 2.6 does not insert the document if any indexing does not work)
values[key] = S(values[key]).truncate(250).toString();
}
}
//
// .required

@@ -194,0 +216,0 @@ //

2

package.json
{
"name": "castor-load-custom",
"version": "1.3.0",
"version": "1.4.0",
"description": "custom loader for castor",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,5 +11,5 @@ Customizable loader for castor

## customFields
## documentFields
All the settings concerning custom fields are put in `customFields`
All the settings concerning custom fields are put in `documentFields`
key in that configuration file.

@@ -20,3 +20,3 @@

```javascript
"customFields": {
"documentFields": {
"title" : {

@@ -54,3 +54,3 @@ "path" : "content.json.Ti"

```javascript
"customFields" : {
"documentFields" : {
"Keywords" : {

@@ -73,3 +73,3 @@ "path" : "content.json.Keywords",

```javascript
"customFields" : {
"documentFields" : {
"doi" : {

@@ -88,3 +88,3 @@ "path" : "content.json.doi"

```javascript
"customFields" : {
"documentFields" : {
"doi" : {

@@ -115,3 +115,3 @@ "label" : "Document Object Identifier"

{
"customFields" : {
"documentFields" : {
"year" : {

@@ -162,3 +162,3 @@ "path" : ["foo","content.json.Py"],

```javascript
"customFields" : {
"documentFields" : {
"title" : {

@@ -183,3 +183,3 @@ "default" : "No title given"

```javascript
"customFields" : {
"documentFields" : {
"slug" : {

@@ -200,3 +200,3 @@ "path" : "content.json.title"

```javascript
"customFields" : {
"documentFields" : {
"title" : {

@@ -212,3 +212,3 @@ "path" : "content.json.title"

```javascript
"customFields" : {
"documentFields" : {
"Keywords" : {

@@ -235,3 +235,3 @@ "path" : "content.json.Kw"

```javascript
"customFields" : {
"documentFields" : {
"Keywords" : {

@@ -252,3 +252,3 @@ "path" : "content.json.Keywords",

```javascript
"customFields" : {
"documentFields" : {
"Year" : {

@@ -271,4 +271,4 @@ "path" : "content.json.Py",

Compute a [funex](https://github.com/masyl/funex) expression, on
the already generated `customFields`.
You can access to the `customFields.Year` simply using `Year`.
the already generated `documentFields`.
You can access to the `documentFields.Year` simply using `Year`.

@@ -278,3 +278,3 @@ Ex:

```javascript
"customFields" : {
"documentFields" : {
"Authors" : {

@@ -298,3 +298,3 @@ "path" : "content.json.Af",

```javascript
"customFields" : {
"documentFields" : {
"Authors" : {

@@ -312,3 +312,3 @@ "path" : "content.json.Af",

### required
Set it to true to indicate that this custom field should be exists to load document
Set it to true to indicate that this custom field should be exists to load document
**Optional** (default value: _false_)

@@ -319,3 +319,3 @@

```javascript
"customFields" : {
"documentFields" : {
"check" : {

@@ -327,1 +327,70 @@ "path" : "content.json.title",

```
### noindex
Set it to true to indicate that this custom field should not be indexed (and truncated) by MongoDB
**Optional** (default value: _false_)
Ex:
```javascript
"documentFields" : {
"abstract" : {
"path" : "content.json.abstract",
"noindex" : true
}
},
```
### mapping
Data mappings between the value of a custom field and a static value.
Static values could declared as hash table or as array
**Optional**
Ex with array:
```javascript
"documentFields" : {
"Month" : {
"path" : "content.json.month",
"type": "number",
"mapping" : [
"janvier",
"février",
"mars",
"avril",
"mai",
"juin",
"juillet",
"août",
"septembre",
"octobre",
"novembre",
"décembre"
]
}
},
```
Ex with hash table:
```javascript
"documentFields" : {
"Month" : {
"path" : "content.json.month",
"mapping" : {
"JAN" : "janvier",
"FEV" : "février",
"MAR" : "mars",
"AVR" : "avril",
"MAI" : "mai",
"JUN" : "juin",
"JUL" : "juillet",
"AOU" : "août",
"SEP" : "septembre",
"OCT" : "octobre",
"NOV" : "novembre",
"DEC" : "décembre"
}
}
},
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc