<commit_before>import * as mongoose from 'mongoose';
import {RoleModel} from './role.model';
import {IRoleAttributeName, RoleAttributeNameModel} from './roleAttributeName.model';
import {
    RoleAttribute as DTO
} from '../../../commons/RamAPI';

// force schema to load first (see https://github.com/atogov/RAM/pull/220#discussion_r65115456)

/* tslint:disable:no-unused-variable */
const _RoleModel = RoleModel;

/* tslint:disable:no-unused-variable */
const _RoleAttributeNameModel = RoleAttributeNameModel;

// enums, utilities, helpers ..........................................................................................

// schema .............................................................................................................

const RoleAttributeSchema = new mongoose.Schema({
    value: {
      type: String,
      required: false,
      trim: true
    },
    attributeName: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'RoleAttributeName',
        required: true
    }
});

// interfaces .........................................................................................................

export interface IRoleAttribute extends mongoose.Document {
    value?: string;
    attributeName: IRoleAttributeName;
    toDTO():Promise<DTO>;
}

/* tslint:disable:no-empty-interfaces */
export interface IRoleAttributeModel extends mongoose.Model<IRoleAttribute> {

}

// instance methods ...................................................................................................

RoleAttributeSchema.method('toDTO', async function () {
    return new DTO(
        this.value,
        await this.attributeName.toHrefValue(true)
    );
});

// static methods .....................................................................................................

// concrete model .....................................................................................................

export const RoleAttributeModel = mongoose.model(
    'RoleAttribute',
    RoleAttributeSchema) as IRoleAttributeModel;
<commit_msg>RAM-4 RAM-516 Change role attribute value to array<commit_after>import * as mongoose from 'mongoose';
import {RoleModel} from './role.model';
import {IRoleAttributeName, RoleAttributeNameModel} from './roleAttributeName.model';
import {
    RoleAttribute as DTO
} from '../../../commons/RamAPI';

// force schema to load first (see https://github.com/atogov/RAM/pull/220#discussion_r65115456)

/* tslint:disable:no-unused-variable */
const _RoleModel = RoleModel;

/* tslint:disable:no-unused-variable */
const _RoleAttributeNameModel = RoleAttributeNameModel;

// enums, utilities, helpers ..........................................................................................

// schema .............................................................................................................

const RoleAttributeSchema = new mongoose.Schema({
    value: {
      type: [String],
      required: false,
      trim: true
    },
    attributeName: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'RoleAttributeName',
        required: true
    }
});

// interfaces .........................................................................................................

export interface IRoleAttribute extends mongoose.Document {
    value?: [string];
    attributeName: IRoleAttributeName;
    toDTO():Promise<DTO>;
}

/* tslint:disable:no-empty-interfaces */
export interface IRoleAttributeModel extends mongoose.Model<IRoleAttribute> {

}

// instance methods ...................................................................................................

RoleAttributeSchema.method('toDTO', async function () {
    return new DTO(
        this.value,
        await this.attributeName.toHrefValue(true)
    );
});

// static methods .....................................................................................................

// concrete model .....................................................................................................

export const RoleAttributeModel = mongoose.model(
    'RoleAttribute',
    RoleAttributeSchema) as IRoleAttributeModel;

{'fraction_non_alphanumeric': 0.3728732326863168, 'fraction_numerical': 0.006230529595015576, 'mean_word_length': 1.2513484358144553, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3218817', 'n_tokens_mistral': 899, 'n_tokens_neox': 899, 'n_words': 201}