Hi All
I'm trying to add a model to my Foxx App, namely 'PropertyTypes'.
I've created propertytype.js with a simple schema.
I've created a simple PropertyTypes.js in repositories.
I'm now trying to get the controllers working, but running into a weird problem.
(Also, I think the code may be wrong, but its copy/paste from my other app which works).
The collection does exist.
ArangoDB 2.6.2 on Mac OS X.
Controllers code bellow results in:
ArangoError 3103: failed to invoke module
'use strict';
var _ = require('underscore');
var joi = require('joi');
var Foxx = require('org/arangodb/foxx');
var ArangoError = require('org/arangodb').ArangoError;
var PropertyTypes = require('repositories/propertytypes');
var PropertyType = require('models/propertytype');
var controller = new Foxx.Controller(applicationContext);
var db = require('org/arangodb').db;
var PropertyTypeIdSchema = joi.string().required()
.description('The id of the Property Type')
.meta({allowMultiple: false});
/**
* Something wrong here
* Deleting the code below allows the Foxx app to work.
* Also, looks weird, PropertyTypes = new PropertyTypes???
**/
var PropertyTypes = new PropertyTypes(
applicationContext.collection('PropertyTypes'),
{model: PropertyType}
);
/** Creates a new item.
*
* Creates a Property Type
*/
controller.post('/', function (req, res) {
var aType = req.parameters.PropertyType;
var newType = PropertyTypes.createOrSavePropertyType( aType.forClient() );
res.json(newType);
})
.bodyParam('PropertyType', {
description: 'The Property Type you want to create',
type: PropertyType
})
.errorResponse(ArangoError, 404, 'The PropertyType could not be created');
/** Lists of all Attribute Types.
*
* This function simply returns the list of all Property Types.
*/
controller.get('/', function (req, res) {
res.json(_.map(PropertyTypes.all(), function (model) {
return model.forClient();
}));
});