Files
wekan/models/team.js
T
Lauri Ojansivu bb4a013939 Collection schemas share one createdAt and one modifiedAt autoValue.
34 schema files wrote the same two autoValue functions out by hand, 65
times in five spellings: createdAt set on insert and $setOnInsert on upsert,
unset otherwise; modifiedAt set on every write. They are now
createdAtAutoValue and modifiedAtAutoValue in models/lib/schemaTimestamps.js,
named by each field as `autoValue: createdAtAutoValue`. models/settings.js,
which may not use import statements, requires them.

Schemas whose rule differs keep their own: changeHistory keeps a createdAt
the caller set, and listSyncCredentials' updatedAt does not unset.

tests/schemaTimestamps runs both functions in SimpleSchema's insert, upsert,
update and validation contexts, and fails when a schema writes either one
out by hand again.

Thanks to xet7 !
2026-11-21 18:27:03 +02:00

89 lines
2.0 KiB
JavaScript

import { Mongo } from 'meteor/mongo';
import { ReactiveCache } from '/imports/reactiveCache';
import { createdAtAutoValue, modifiedAtAutoValue } from '/models/lib/schemaTimestamps';
const { SimpleSchema } = require('/imports/simpleSchema');
const Team = new Mongo.Collection('team');
/**
* A Team in WeKan. Organization in Trello.
*/
Team.attachSchema(
new SimpleSchema({
teamDisplayName: {
/**
* the name to display for the team
*/
type: String,
optional: true,
},
teamDesc: {
/**
* the description the team
*/
type: String,
optional: true,
max: 190,
},
teamShortName: {
/**
* short name of the team
*/
type: String,
optional: true,
max: 255,
},
teamWebsite: {
/**
* website of the team
*/
type: String,
optional: true,
max: 255,
},
teamIsActive: {
/**
* status of the team
*/
type: Boolean,
optional: true,
},
teamSharedTemplates: {
/**
* #5850: members may drag personal Template Boards onto this team to share
* (per-team form of "Shared Templates for Teams"). Off by default.
*/
type: Boolean,
optional: true,
},
teamPropagateMembersToBoards: {
/**
* #4737: add this team's members to the boards that list this team. Off by default.
*/
type: Boolean,
optional: true,
},
teamSyncMembersFromAuth: {
/**
* #4737: this team's membership is maintained by the authentication
* provider's group/membership sync (LDAP, OAuth2/OIDC, SAML, etc.). Off by default.
*/
type: Boolean,
optional: true,
},
createdAt: {
/**
* creation date of the team
*/
type: Date,
autoValue: createdAtAutoValue,
},
modifiedAt: {
type: Date,
autoValue: modifiedAtAutoValue,
},
}),
);
export default Team;