<commit_before>import SimpleSchema from 'simpl-schema'
import { Mongo } from 'meteor/mongo'

export Vessels = new Mongo.Collection 'vessels'

Vessels.deny
	insert: -> true
	update: -> true
	remove: -> true

Vessels.schemaObj =

	_id:
		type: String
		autoValue: -> Random.id() unless @isSet
	createdAt:
		type: Date
		autoValue: -> new Date
	createdBy:
		type: String
		autoValue: -> Meteor.userId()
	name:
		type: String
	flag:
		type: String
		optional: true
	type:
		type: String
		dropdown: 'vesselType'
		allowedValues: ['c', 'cr', 'mf', 'mt', 'p', 'pt', 'rc', 'f', 'ro', 't', 'unknown']
	callsign:
		type: String
		optional: true
	eni:
		type: String
		optional: true
	imo:
		type: String
		optional: true
	mmsi:
		type: String
		optional: true
	lastVisit:
		type: Date
		optional: true
	harborGroup:
		type: String
		readonly: true
	nextVisit:
		type: Date
		optional: true
	languages:
		type: String
		optional: true
	comments:
		type: String
		optional: true

schemaObj = {}

for schemaObjKey, schemaObjValue of Vessels.schemaObj
	schemaObj[schemaObjKey] = {}

	for keyAttr, keyValue of schemaObjValue when keyAttr not in ['dropdown', 'readonly']
		schemaObj[schemaObjKey][keyAttr] = keyValue

Vessels.schema = new SimpleSchema(schemaObj)

Vessels.attachSchema = Vessels.schema<commit_msg>add visits array to schema; remove non-schematic values<commit_after>import SimpleSchema from 'simpl-schema'
import { Mongo } from 'meteor/mongo'

export Vessels = new Mongo.Collection 'vessels'

Vessels.deny
	insert: -> true
	update: -> true
	remove: -> true

Vessels.schema = new SimpleSchema

	_id:
		type: String
		autoValue: -> Random.id() unless @isSet
	createdAt:
		type: Date
		autoValue: -> new Date
	createdBy:
		type: String
		autoValue: -> Meteor.userId()
	name:
		type: String
	flag:
		type: String
		optional: true
	type:
		type: String
		allowedValues: ['c', 'cr', 'mf', 'mt', 'p', 'pt', 'rc', 'f', 'ro', 't', 'unknown']
	callsign:
		type: String
		optional: true
	eni:
		type: String
		optional: true
	imo:
		type: String
		optional: true
	mmsi:
		type: String
		optional: true
	visits:
		type: Array
	'visits.$': new SimpleSchema
		userId:
			type: String
		isUserVisible:
			type: Boolean
		harborGroupId:
			type: String
		date:
			type: Date
			optional: true
		dateNext:
			type: Date
			optional: true
		languages:
			type: String
			optional: true

Vessels.attachSchema = Vessels.schema
{'fraction_non_alphanumeric': 0.11674283340257582, 'fraction_numerical': 0.0, 'mean_word_length': 3.7401574803149606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '5811938', 'n_tokens_mistral': 948, 'n_tokens_neox': 857, 'n_words': 256}