Bot releases are visible (Hide)
import { Class, Union } from 'meteor/jagi:astronomy';
const StringOrNumber = Union.create({
name: 'StringOrNumber',
types: [String, Number],
cast(value) {
if (typeof value !== 'string') {
return String(value);
}
return value;
}
});
const Item = Class.create({
name: 'Item',
fields: {
strOrNum: StringOrNumber
}
});
user.firstName = 'John';
user.validate({
modified: true
});
Astro.config.defaults
flag is set to false
Astro.config.defaults = false;
User.findOne(); // Default values won't be set
// Required fields:
item.set('number', '', {cast: true}); // Casts to 0
item.set('boolean', '', {cast: true}); // Casts to false
item.set('date', '', {cast: true}); // Does not cast
item.set('object', '', {cast: true}); // Does not cast
item.set('list', '', {cast: true}); // Does not cast
// Optional fields:
item.set('number', '', {cast: true}); // Casts to null
item.set('boolean', '', {cast: true}); // Casts to null
item.set('date', '', {cast: true}); // Casts to null
item.set('object', '', {cast: true}); // Casts to null
item.set('list', '', {cast: true}); // Casts to null
doc._isNew
and introduce a new Class.isNew
method and fix a bug with wrong value of the doc._isNew
property in the afterInit
eventconst Item = Class.create({
name: 'Item',
collection: new Mongo.Collection('items'),
events: {
afterInsert(e) {
const doc = e.target;
Item.isNew(doc);
}
}
});
raw()
method.get()
method.user.set({
firstName: 123 // Will be casted to the "123" string
}, {
cast: true
});
const user = new User(userFormData);
user.save({
cast: true
});
const user = new User(userFormData);
user.validate({
cast: true
});
const addressData = {
state: 'CA'
};
// Will not override the "city" property in address.
user.set('address', addressData, {
merge: true
});
find()
methodconst users = User.find(selector, {
defaults: false
}).fetch();
Astro.config.resolving = false;