I am using sails#beta.
I am trying to create several Room models (see definition) below, the problem is that I can successfully create Room models with the same attribute 'name', although attribute 'name' has a unique validation.
The validation isn't detected until the next restart of 'sails' server, then I get this output:
C:\eMali_dev\server>sails lift
info: Starting app...
Express midleware for passport
Waterline encountered a fatal error when trying to perform the `alter` auto-migration strategy.
In a couple of seconds, the data (cached in memory) will be logged to stdout.
(a failsafe put in place to preserve development data)
In the mean time, here's the error:
Error (E_UNKNOWN) :: Encountered an unexpected error:
MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1 dup key: { : "e1" }
Details:
{ error: 'E_UNKNOWN',
summary: 'Encountered an unexpected error',
status: 500,
raw: 'MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1 dup key: { : "e1" }' }
================================
Data backup:
================================
[ { name: 'e1',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 6,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióc' } },
{ name: 'e2',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 7,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióª' } },
{ name: 'e1',
center: '53471e2318b931dc1b69f3a8',
min_age: 1,
max_age: 6,
createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
_id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bió«' } } ]
error: A hook (`orm`) failed to load!
Room model:
module.exports = {
schema: true,
attributes: {
name: {
type: 'string',
required: true,
unique: true,
minLength: 3
},
center: {
model: 'center'
},
min_age: {
type: 'integer',
required: true
},
max_age: {
type: 'integer',
required: true
}
}
}
This was a bug in sails and it was fixed. Thanks everybody
You need to change the database from default Disk database to a database of your choice.
I was facing a similar problem and changing database from "Disk" to "MongoDB" fixed my issue.
It seems the default database is unable to enforce unique constraint.
I hope it solves your issue.
Related
When getting the order information form the api we get the fulfilment status but not the exact time when the order was fulfilled. The fulfilment information from the api is missing.
The fulfilment object in an order has the following properties.
fulfillments: [
{
id: NUMBER,
admin_graphql_api_id: 'gid://shopify/Fulfillment/NUMBER',
created_at: '2022-01-04T11:07:59-05:00',
location_id: NUMBER,
name: 'STRING',
order_id: NUMBER,
receipt: {},
service: 'manual',
shipment_status: null,
status: 'success',
tracking_company: 'ACME',
tracking_number: 'NUMBER',
tracking_numbers: [Array],
tracking_url: 'https://acme.com/TrackConfirmAction?qtc_tLabels1=NUMBER',
tracking_urls: [Array],
updated_at: '2022-01-04T11:08:00-05:00',
line_items: [Array]
}
],
created_at has the information when the fulfilment was created and updated at could have the information when it was even shipped/delivered. How do I get this time, pointers to documentation would be really appreciated.
I want to store data in the following style in Redis database:
{ _id: 5b3a60cdccbdf81bcc5343e6,
id: 5b3a60cdccbdf81bcc5343e5,
position: 'Web dveloper',
type: 'Contract',
Skills: 'html, bootstrap,php',
location: 'Boston',
job_id: 1,
Experience: '0-6 months',
Description: 'Developer for websites and web apps',
__v: 0 },
{ _id: 5b3a6151ccbdf81bcc5343e8,
id: 5b3a6151ccbdf81bcc5343e7,
position: 'Data analyst',
type: 'contract',
Skills: 'big data, hadoop,python',
location: 'boston',
job_id: 2,
Experience: '1yr',
Description: 'for analysing incoming data',
__v: 0 },
{ _id: 5b3a6207ccbdf81bcc5343ea,
id: 5b3a6207ccbdf81bcc5343e9,
position: 'Content Writer',
type: 'Permanent',
Skills: 'Technical wirtting,Custmer engagement',
location: 'new jersey',
job_id: 3,
Experience: '0-6 months',
Description: 'for writting website content',
__v: 0 },
{ _id: 5b3a62c4ccbdf81bcc5343ec,
id: 5b3a62c4ccbdf81bcc5343eb,
position: 'node js specialist',
type: 'Permanent',
Skills: 'node js ,express js , mean stack',
location: 'boston',
job_id: 4,
Experience: '1yr',
Description: 'for the web apps',
__v: 0 },
{ _id: 5b3a6362ccbdf81bcc5343ee,
id: 5b3a6362ccbdf81bcc5343ed,
position: 'database expert',
type: 'temporary',
Skills: 'sql , no sql, mysql,sql server,mongo db',
location: 'boston',
job_id: 5,
Experience: '2 yrs',
Description: 'for desinging and maintaing databases',
__v: 0 },
{ _id: 5b3a8639c8323b2cfc179969,
id: 5b3a8639c8323b2cfc179968,
position: 'Social media manager',
type: 'Permanent',
Skills: 'Social media marketing,Digital marketing',
location: 'Boston',
job_id: 4,
Experience: '1yr',
Description: 'For managing company socail media accounts',
__v: 0 }
I have gone through Redis official documentation but I have found nothing. Can anybody guide what structure I can use to store and how I can retrieve these data in table?
One of the alternatives you could use to store your data is the Redis Hash data structure. Using the Redis Hash structure, you could store your entities using the id as the key, then map the remaining fields into a Redis Hash using the HMSET command.
The recommended client for Node.js is the npm Redis package. This will provide all of the functionality you need to interact with Redis.
Ultimately, your query patterns are going to determine the optimal structure for your data. Using a hash is a very basic entity mapping approach to the problem, but it might not be the best way to structure the data. There may be more efficient ways to structure the data depending on how you plan to use it.
Redis doesn't offer that much structure directly, but there are layered libraries that do. I am trying to use Walrus, a Python library, that offers that capability atop Redis.
I'm trying to proxy an S3 bucket configured as a website from an API Gateway endpoint. I configured an endpoint successfully using the console, but I am unable to recreate the configuration using Cloudformation.
After lots of trial and error and guessing, I've come up with the following CF stack template that gets me pretty close:
Resources:
Api:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Name: ApiDocs
Resource:
Type: 'AWS::ApiGateway::Resource'
Properties:
ParentId: !GetAtt Api.RootResourceId
RestApiId: !Ref Api
PathPart: '{proxy+}'
RootMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: ANY
ResourceId: !GetAtt Api.RootResourceId
RestApiId: !Ref Api
AuthorizationType: NONE
Integration:
IntegrationHttpMethod: ANY
Type: HTTP_PROXY
Uri: 'http://my-bucket.s3-website-${AWS::Region}.amazonaws.com/'
PassthroughBehavior: WHEN_NO_MATCH
IntegrationResponses:
- StatusCode: 200
ProxyMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: ANY
ResourceId: !Ref Resource
RestApiId: !Ref Api
AuthorizationType: NONE
RequestParameters:
method.request.path.proxy: true
Integration:
CacheKeyParameters:
- 'method.request.path.proxy'
RequestParameters:
integration.request.path.proxy: 'method.request.path.proxy'
IntegrationHttpMethod: ANY
Type: HTTP_PROXY
Uri: 'http://my-bucket.s3-website-${AWS::Region}.amazonaws.com/{proxy}'
PassthroughBehavior: WHEN_NO_MATCH
IntegrationResponses:
- StatusCode: 200
Deployment:
DependsOn:
- RootMethod
- ProxyMethod
Type: 'AWS::ApiGateway::Deployment'
Properties:
RestApiId: !Ref Api
StageName: dev
Using this template I can successfully get the root of the bucket website, but the proxy resource gives me a 500:
curl -i https://abcdef.execute-api.eu-west-1.amazonaws.com/dev/index.html
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 36
Connection: keep-alive
Date: Mon, 11 Dec 2017 16:36:02 GMT
x-amzn-RequestId: 6014a809-de91-11e7-95e4-dda6e24d156a
X-Cache: Error from cloudfront
Via: 1.1 8f6f9aba914cc74bcbbf3c57e10df26a.cloudfront.net (CloudFront)
X-Amz-Cf-Id: TlOCX3eemHfY0aiVk9MLCp4qFzUEn5I0QUTIPkh14o6-nh7YAfUn5Q==
{"message": "Internal server error"}
I have no idea how to debug that 500.
To track down what may be wrong, I've compared the output of aws apigateway get-resource on the resource I created manually in the console (which is working) with the one Cloudformation made (which isn't). The resources look exactly alike. The output of get-method however, is subtly different, and I'm not sure it's possible to make them exactly the same using Cloudformation.
Working method configuration:
{
"apiKeyRequired": false,
"httpMethod": "ANY",
"methodIntegration": {
"integrationResponses": {
"200": {
"responseTemplates": {
"application/json": null
},
"statusCode": "200"
}
},
"passthroughBehavior": "WHEN_NO_MATCH",
"cacheKeyParameters": [
"method.request.path.proxy"
],
"requestParameters": {
"integration.request.path.proxy": "method.request.path.proxy"
},
"uri": "http://muybucket.s3-website-eu-west-1.amazonaws.com/{proxy}",
"httpMethod": "ANY",
"cacheNamespace": "abcdefg",
"type": "HTTP_PROXY"
},
"requestParameters": {
"method.request.path.proxy": true
},
"authorizationType": "NONE"
}
Configuration that doesn't work:
{
"apiKeyRequired": false,
"httpMethod": "ANY",
"methodIntegration": {
"integrationResponses": {
"200": {
"responseParameters": {},
"responseTemplates": {},
"statusCode": "200"
}
},
"passthroughBehavior": "WHEN_NO_MATCH",
"cacheKeyParameters": [
"method.request.path.proxy"
],
"requestParameters": {
"integration.request.path.proxy": "method.request.path.proxy"
},
"uri": "http://mybucket.s3-website-eu-west-1.amazonaws.com/{proxy}",
"httpMethod": "ANY",
"requestTemplates": {},
"cacheNamespace": "abcdef",
"type": "HTTP_PROXY"
},
"requestParameters": {
"method.request.path.proxy": true
},
"requestModels": {},
"authorizationType": "NONE"
}
The differences:
The working configuration has responseTemplates set to "application/json": null. As far as I can tell, there's no way to set a mapping explicitly to null using Cloudformation. My CF method instead just has an empty object here.
My CF method has "responseParameters": {},, while the working configuration does not have responseParameters at all
My CF method has "requestModels": {},, while the working configuration does not have requestModels at all
Comparing the two in the console, they are seemingly exactly the same.
I'm at my wits end here: what am I doing wrong? Is this possible to achieve using Cloudformation?
Answer: The above is correct. I had arrived at this solution through a series of steps, and re-applied the template over and over. Deleting the stack and deploying it anew with this configuration had the desired effect.
When I switch from Chrome to PhantomJS I get the following errorh
Starting 'unit'...
03 08 2016 21:39:43.629:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
03 08 2016 21:39:43.643:INFO [launcher]: Starting browser PhantomJS
03 08 2016 21:39:44.355:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#ns0iei_Fprf487aCAAAA with id 15517298
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
SyntaxError: Expected an identifier but found 'originalDefine' instead
at /home/xenoterracide/IdeaProjects/rpf-ui/test/aurelia-karma.js:49
{ uid: 0,
name: 'unit',
branch: false,
error: 1,
duration: [ 1, 91922852 ],
time: 1470278384500 }
1
Here is the karma.conf.js generated by Aurelia.
"use strict";
const path = require('path');
const project = require('./aurelia_project/aurelia.json');
const tsconfig = require('./tsconfig.json');
let testSrc = [
{ pattern: project.unitTestRunner.source, included: false },
'test/aurelia-karma.js'
];
let output = project.platform.output;
let appSrc = project.build.bundles.map(x => path.join(output, x.name));
let entryIndex = appSrc.indexOf(path.join(output, project.build.loader.configTarget));
let entryBundle = appSrc.splice(entryIndex, 1)[0];
let files = [entryBundle].concat(testSrc).concat(appSrc);
module.exports = function(config) {
config.set({
basePath: '',
frameworks: [project.testFramework.id],
files: files,
exclude: [],
preprocessors: {
[project.unitTestRunner.source]: [project.transpiler.id]
},
typescriptPreprocessor: {
typescript: require('typescript'),
options: tsconfig.compilerOptions
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};
I ran into this issue just now. I 'solved' it by modifying aurelia-karma.js at line 49 from:
let originalDefine = global.define;
to:
var originalDefine = global.define;
Currently don't have time to find a root cause for this, may come back and edit later. Suspect this might be a typescript/transpiling issue with let compatibility.
(Node v4.4.7, Karma 0.13.22, jasmine v2.4.1, Aurelia-cli v0.17.0)
I am trying to access the "Planned Velocity" field which is available for Iterations using the Rally 2.0 API and a WsapiDataStore object. Even when using fetch: true in development to pull back all fields, I do not see this field.
Does anyone know how to access this field?
Thanks,
Michael
Code excerpt:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
this.loadIterations();
},
loadIterations: function() {
var iterations = Ext.create('Rally.data.WsapiDataStore', {
model: 'Iteration',
autoLoad: true,
fetch: ['ObjectID', 'Name', 'EndDate', 'PlannedVelocity'],
sorters: [
{property: 'EndDate', direction: 'ASC'}
],
listeners: {
load: function(store, data, success) {
Ext.Array.each(data, function(record) {
console.info('ID: ', record.get('ObjectID'),
' Name: ', record.get('Name'),
' EndDate: ', record.get('EndDate'),
' PlannedVelocity: ', record.get('PlannedVelocity'));
});
}, scope: this
}
});
}
});
Console Output:
ID: 12351801409 Name: AGR 4.2 Iteration 1 EndDate: Date {Tue Jul 02 2013 23:59:59 GMT-0400 (Eastern Standard Time)} PlannedVelocity: undefined
ID: 12351802932 Name: AGR 4.2 Iteration 2 EndDate: Date {Tue Jul 23 2013 23:59:59 GMT-0400 (Eastern Standard Time)} PlannedVelocity: undefined
ID: 13298563033 Name: AGR 4.2 Iteration 3 EndDate: Date {Tue Aug 13 2013 23:59:59 GMT-0400 (Eastern Standard Time)} PlannedVelocity: undefined
ID: 12351804786 Name: AGR 4.2 Iteration 4 EndDate: Date {Tue Sep 03 2013 23:59:59 GMT-0400 (Eastern Standard Time)} PlannedVelocity: undefined
Rally Info:
Name End Date Planned Velocity
AGR 4.2 Iteration 1 7/2/2013 29.0 Points
AGR 4.2 Iteration 2 7/23/2013 82.0 Points
AGR 4.2 Iteration 3 8/13/2013 70.5 Points
AGR 4.2 Iteration 4 9/3/2013 72.4 Points
PlannedVelocity is the name of the field to include in the fetch (no spaces). If that still doesn't work please provide some example code so it is easier to see what might be going on.