In another question people were using !: in an entiy description.
what is the meaning of !: ?
example:
#Column({
type: 'text',
unique: true,
nullable: true,
})
resetPasswordToken!: string;
i think ?: means its an optional parameter, but what is the meaning of !: ?
Related
I am making a simple personality quiz but I want some of my answers to fall under multiple personality types, not just one.
Here is working code where answers attribute to one specific PersonalityType:
var questions: [Question] = [
Question(text: "Pick one that best describes you", //Single choice answers
type: .single,
answers: [
Answer(text: "Healthy", type: .extrovert,),
Answer(text: "Average", type: .average),
Answer(text: "Unfit", type: .neuro),
]),
I want to achieve something along the lines of Answer(text: "Healthy", type: .extrovert, .fit), So that answering Healthy matches a 'extrovert' and 'fitness' personality type.
I think it's because I am using enum to record Personality Type String:
struct Answer {
var text: String
var type: PersonalityType
}
enum PersonalityType: String {
case fit = "Fitness", extrovert = "Extrovert", average = "Average", neuro = "Neuroticism" //personality type
In Answer struct use var type: [PersonalityType] instead of var type: PersonalityType.
When add answers, use like this: Answer(text: "Healthy", type: [.extrovert, .fit])
I am defining a RAML 1.0 datatype with property that can be 'nil.' The type of that property is an !included datatype which, whilst not giving any errors in the datatype definition causes the root object to throw a "Unresolved reference '!includereference-data.raml' at libraries/types/personal-details.raml (10, 12)'
I've tried converting the DataType to a library to try and implement a "uses" or "types" but that impacts all the other objects that include this data type.
#%RAML 1.0 DataType
properties:
DateOfBirth: datetime
FirstName: string
FamilyName: nil | string
PreferredName: nil | string
PreviousNames: nil | string
Title: !include reference-data.raml
Gender: nil | !include reference-data.raml
The 'Title' property is working as expected, the error is thrown against the Gender property - I actually want both to be nillable.
The datatype to hold nillable properties here is "name_block.raml"
#%RAML 1.0 DataType
uses:
lib: base_types.raml
type: object
properties:
FirstName: lib.string30
MiddleName: lib.nstring30
LastName: lib.string150
The included library (base_types.raml) is defined as
#%RAML 1.0 Library
types:
string30:
type: string
minLength: 0
maxLength: 30
string150:
type: string
minLength: 0
maxLength: 150
nstring30:
type: string | nil
If anyone knows of a better way - It would be great to see it.
When including a createdAt field in my datamodel.prisma schema the DateTime! returns a null value.
I am raising this on here so that if anyone else has the same problem, hopefully they will be able to find this post.
// in datamodel.prisma
type User {
id: ID! #id
trade_no: String!
name: String!
email: String!
createdAt: DateTime!
}
Error message looks like this "Reason: 'createdAt' Expected non-null value, found null."
In mongoDB the createdAt must be written as
type User {
id: ID! #id
trade_no: String!
name: String!
email: String!
created_at: DateTime! #createdAt
}
when used with Prisma (don't know if this is the case for other databases). Also, bear in mind that the #relation directive must have link: INLINE as an argument (the relationship is stored in the record, not in a separate table). Took me a while to work this out so I thought I'd put it here.
It's worth having a look at https://www.prisma.io/docs/releases-and-maintenance/features-in-preview/mongodb-b6o5/ for other specificities with Prisma & mongoDB.
In my schema I need to have a propery that is an array that must be always not null and not undefined.
So I defined it required, but the validation is not working as I expected, because if I omit the property no error is throw.
In case of simple property (not an array) this work as I expected
const nodeSchema = new Schema({
address: { type: String, required: true },
outputs: { type: [String], required: true }
})
I think you can fix it adding a custom validator like this:
const nodeSchema = new Schema({
address: { type: String, required: true },
outputs: {
type: [String],
required: true,
validate: [(value) => value.length > 0, 'No outputs'],
}
})
I hope it helps you.
Arrays implicitly have a default value of [] (empty array).
This was the problem
Array implicitly have a default value of [] (empty array).
if you add default: undefined it will fix the issue.
Using CloudKit.js, how do I construct a query that matches items where a field is nil? Every permutation I've tried fails - either it's clearly matching on a string value (i.e. "null" or "nil") or it throws an error if I actually try to pass 'null'.
Any ideas? None of the below work.
filterBy: [{
fieldName: 'customerNumber',
comparator: 'EQUALS',
fieldValue: { value: "nil" }
}]
filterBy: [{
fieldName: 'customerNumber',
comparator: 'EQUALS',
fieldValue: { value: null }
}]
filterBy: [{
fieldName: 'customerNumber',
comparator: 'EQUALS',
fieldValue: { value: "null" }
}]
filterBy: [{
fieldName: 'customerNumber',
comparator: 'EQUALS',
fieldValue: { value: "" }
}]
I don't think there is any option to query for nil values in CloudKit. Also not from native code. I have tried a lot of predicates, but non seems to work.
You do have to be aware that CloudKit is a key-value store. When a value is nil, then the key won't be there in the record. There is no option to query for non existing keys.
The closest I have come to a good solution was with a predicate with the format "NOT myField => ''" sorry, don't know the format for .js
In the CloudKit CKQuery documentation there is nothing mentioned about nil fields.
In the documentation for NSPredicates there are sample's for nil values.
But it was already clear that CloudKit has implemented only a subset of the possibilities of NSPredicate (see CKQuery class reference)
I think the best way to handle this is by not using/depending on nil values. If you do need to check some nil status, then instead you could add an extra field that would represent that status.