Sails-mongo many to many association not working - node.js

I am using sails 0.10.5 , and i have two models as below for many to many relation. but i am getting error while lifting app.
model 1) Category.js
attributes: {
name: {
type: 'string',
required: true
},
features: {
type: 'array'
},
desc: {
type: 'string'
},
sub_cats: {
collection: 'SubCategory',
via: 'cats',
dominant: true
}
}
model 2) SubCategory.js
attributes: {
cats: {
collection: 'Category',
via: 'sub_cats'
},
name: {
type: 'string',
required: true
},
features: {
type: 'array'
},
desc: {
type: 'string'
}
}
Now while lifting sails app, this error always trigger
"C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" app.js
c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47
return hop.call(obj, prop);
^
TypeError: Cannot convert null to object
at hasOwnProperty (native)
at exports.object.hasOwnProperty (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47:14)
at JoinTables.parseAttribute (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:148:26)
at c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:83:22
at Array.forEach (native)
So i am confused (my code is wrong or there is some problem in sails-mongo many-many relation)
--ND

It is just a typo in SubCategory.js: It should be attributes instead of attribute.

Hopefully you've solved your problem by now! For others like me who ran into this error, balderdashy/waterline-schema just released a more helpful error message at https://github.com/balderdashy/waterline-schema/issues/17 which should help you figure out your particular problem. Because as of today (2015-04-28) npm install does not get you this most recent version, you can manually fix it by doing the following:
Navigate to node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema (note: this may be in your global sails directory)
Replace joinTables.js with https://github.com/balderdashy/waterline-schema/blob/8f5a44d076ca36edea409bf41ac2cdbf760c2c59/lib/waterline-schema/joinTables.js
I know this doesn't exactly answer your question as to what went wrong, but hopefully it will give others with that error the tools to solve it more quickly.

Related

need an appropriate loader to handle this file type in audio files

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
i get this error when i want to console.log my audio files in array in my audioData.js
here is my audioData.js :
export const audios =[
{
name: 'Ağlatma Gelem',
artist: 'Oğuz Aksaç',
music: require('../audios/oguz-aksac-aglatma-gelem.mp3')
},
{
name: 'NKBİ',
artist: 'Güneş',
music: require('../audios/gunes-nkbi.mp3')
},
{
name: 'Goge Bakmak Icin',
artist: 'Saian, Çagri Sinci',
music: require('../audios/sai-cs-gbi.mp3')
}
]
i noticed that error is about loader(maybe about babel-loader) in my webpack.config.js but i cant solve it

Override error message on eslint-plugin-mocha rule

I'm using eslint-plugin-mocha to put some rules on writing tests with mocha and here is what my .eslintrc.js file looks like
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
plugins: ['mocha'],
extends: 'plugin:mocha/recommended',
rules: {
'mocha/valid-test-description': ['error', /^should/]
},
env: {
'mocha': true
}
}
This rule finds any test description that doesn't start with should.
The error message looks like that
error Invalid "it()" description found mocha/valid-test-description
I'd like the change this error message to be more descriptive but the rule doesn't offer options to change this message. Do you know how with eslint to configure this ?
I've made a PR and this feature is available since version 6.1.0 of eslint-plugin-mocha.
Here is how to define the error message:
rules: {
'mocha/valid-test-description': ['error', { pattern: /^should/, message: 'Should start with "should"' }]
}
// OR
rules: {
'mocha/valid-test-description': ['error', /^should/, ['it', 'specify', 'test'], 'Should start with "should"']
}
The documentation is available here.
Now the error message is:
error Should start with "should" mocha/valid-test-description
Note: the same feature is available for the valid-suite-description rule.

Error when trying to use CanvasJS via RequireJS

I'm trying to use CanvasJS inside my project. I'm using RequireJS to manage the modules, and have this in the main script:
define(['domReady',"canvasjs","common-functions"], function(domReady,CanvasJS) {
domReady(function () {
window.CanvasJS = CanvasJS;
init_page_select();
});
});
This is what I have in my requireJS config file for the path:
"paths": {
// other stuff here
"canvasjs": "node_modules/canvasjs/dist/canvasjs.min"
},
I can see the canvasjs.min.js file being grabbed fine - but then I get this weird error:
ReferenceError: intToHexColorString is not defined[Learn More] canvasjs.min.js:7:7042
[33]</n.prototype.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:7:7042
[28]</n.prototype.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:5:14150
n/this.render https://www.test.org/2018/js/lib/node_modules/canvasjs/dist/canvasjs.min.js:8:17771
init_page_select https://www.test.org/2018/js/lib/spot_view_stats.js:83:2
<anonymous> https://www.test.org/2018/js/lib/spot_view_stats.js:4:3
domReady https://www.test.org/2018/js/lib/domready.js:105:13
<anonymous> https://www.test.org/2018/js/lib/spot_view_stats.js:2:2
execCb https://www.test.org/2018/js/lib/require.js:5:12859
check https://www.test.org/2018/js/lib/require.js:5:6575
enable/</< https://www.test.org/2018/js/lib/require.js:5:9031
bind/< https://www.test.org/2018/js/lib/require.js:5:812
emit/< https://www.test.org/2018/js/lib/require.js:5:9497
each https://www.test.org/2018/js/lib/require.js:5:289
emit https://www.test.org/2018/js/lib/require.js:5:9465
check https://www.test.org/2018/js/lib/require.js:5:7169
enable/</< https://www.test.org/2018/js/lib/require.js:5:9031
bind/< https://www.test.org/2018/js/lib/require.js:5:812
emit/< https://www.test.org/2018/js/lib/require.js:5:9497
each https://www.test.org/2018/js/lib/require.js:5:289
emit https://www.test.org/2018/js/lib/require.js:5:9465
check https://www.test.org/2018/js/lib/require.js:5:7169
enable https://www.test.org/2018/js/lib/require.js:5:9358
init https://www.test.org/2018/js/lib/require.js:5:5716
h https://www.test.org/2018/js/lib/require.js:5:4287
completeLoad https://www.test.org/2018/js/lib/require.js:5:12090
onScriptLoad https://www.test.org/2018/js/lib/require.js:5:13014
I'm invoking it with:
var chart = new CanvasJS.Chart("thegraph",
{
title:{
text: impressionText
},
theme: "theme2",
axisX: {
valueFormatString: "MMM-DD-YYYY",
labelAngle: -50
},
axisY:{
valueFormatString: "#0",
title: impressionText
},
data: [
{
type: "line",
showInLegend: true,
legendText: legendText,
dataPoints: dataPoints
}
]
});
chart.render();
Interestingly, if I tell it to load canvasjs.js instead of canvasjs.min.js, I get another error:
ReferenceError: intToHexColorString is not defined[Learn More]
OK so the problem seemed to be my version. For some reason "npm install canvasjs" was installing 1.8.1, but 2.2 was out. As per their request, I updated it to 2.2 and it sorted the problem. It seems weird npm is running such an outdated version though

swaggerhub and REST API

I use swaggerHub for write the documentation of my new app Node but I have a problem with one api.
My API require two params.
Example : POST http://cloud.amazingwebsite.com/:service/:action
Ok, if you want to use this API, you must to give two values. My problem is that the doc of swaggerHub propose only examples with one param.
Please, do you have a example with two params ? Is it possible ? Thanks
If you do it like this:
"/{service}/{action}":
x-swagger-router-controller: serviceController
post:
summary: To perform an action
operationId: serviceAction
parameters:
- name: service
in: path
required: true
type: string
description: Request Path Param for service
- name: action
in: path
required: true
type: string
description: Request Path Param for Action
responses:
'200':
description: Success
schema:
"$ref": "#/definitions/SuccessResponse"
default:
description: Error
schema:
"$ref": "#/definitions/ErrorResponse"
definitions:
SuccessResponse:
type: object
ErrorResponse:
required:
- error
properties:
error:
type: string

jsonix properties - ogc-schemas .js aren't same

The manual on jsonix properties at https://github.com/highsource/jsonix/wiki/Properties shows properties as being something like:
name: 'MyModule',
typeInfos: [{
type: 'classInfo',
localName: 'InputType',
propertyInfos: [{
type: 'attribute',
typeInfo: 'Boolean',
name: 'checked'
}]
}],
But then (after npm install ogc-schemas) what I am seeing is:
ln: 'TimeClockPropertyType',
ps: [{
n: 'timeClock',
rq: true,
en: 'TimeClock',
ti: '.TimeClockType'
},
With the abbreviated names.
Which should it be and why doesn't it matter if it doesn't?
Disclaimer: I'm the author of jsonix.
This is what's called compact naming. This is an option of the Jsonix Schema Compiler which generates shorter names in mappings, like n instead of name or dens instead of defaultElementNamespaceURI. The goal is clearly to make mappings smaller and since ogc-schemas are pretty large, they are compiled with compact naming by default.
If you want standard naming, fork and remove
<arg>-Xjsonix-compact</arg>
from all the pom.xmls.
Both compact and standard names work in runtime, I think standard names have higher priority.

Resources