kandi X-RAY | lireddit Summary
kandi X-RAY | lireddit Summary
lireddit
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lireddit
lireddit Key Features
lireddit Examples and Code Snippets
Community Discussions
Trending Discussions on lireddit
QUESTION
I'm trying to follow Ben Awad's lireddit tutorial.
At the time he made the tutorial, there may have been different inferences about Field types.
I'm trying to add a Field to my relationship attribute (adding creator Field to a Post), so that I can then access creator attributes on that post record.
Ben does this as follows:
...ANSWER
Answered 2021-Sep-30 at 10:56First of all, creator
should be of a User
type, and not a list of users, i.e.
QUESTION
I'm trying to follow Ben Awad's lireddit tutorial.
He shows how to make a utility file to show any authentication error across the app.
I think things may have changed with the next/router since he made the video. I'm struggling to figure out a way to use the router to redirect inside a hook, inside a component in this way.
I can't put the useRouter hook inside the exchangeError - I think the reason for that is that when I want to use the exchangeError inside other components, the hook is no longer at the top level, but then I can't figure out how to make the exchangeError work without it, or adapt to the udpated version of next/router.
My best attempt (I know I can't use it like this) is below:
...ANSWER
Answered 2021-Sep-21 at 01:37So I spent some time diving into source code. Conclusion:
QUESTION
@Mutation (() => UserResponse)
async register(
@Arg('options', () => UsernamePasswordInput ) options: UsernamePasswordInput,
@Ctx() {em, req}: MyContext
): Promise{
const errors = validateRegister(options);
const hashedPassword = await argon2.hash(options.password)
let user;
try{
/* cast to this type, em as entity manager */
const result = await (em as EntityManager).createQueryBuilder(User).getKnexQuery().insert({
username: options.username,
password: hashedPassword,
email: options.email,
created_at: new Date(),
updated_at: new Date()
}).returning("*");
/* returns all fields back from the user */
user = result[0];
} catch(err: any ) {
if (err.code === '23505' || err.detail.includes("already exists")){
// duplicate name
/* returning errors object */
return {
errors: [{
field: 'username or email',
message: 'that username or email already exists'
}]
}
}
}
req.session.userId = user.id;
return {user};
}
...ANSWER
Answered 2021-Aug-23 at 18:26This usually always happens when a field, which is set up as non-nullable, is being returned as null from the server.
Please check the object which is returned from the server and verify if all the fields which you marked as per your set up, are being returned with some value.
One way to quickly check is to make all as { nullable: true }
and see if that works, and then you can see which one is the offender.
QUESTION
So
Console:
...ANSWER
Answered 2021-Apr-22 at 20:32I have had the same issue. This is what I did:
- I deleted the
migrations
folder as well as thedist
folder - I ran
npx mikro-orm migration:create --initial
After that, I restarted yarn watch
and yarn dev
and it worked for me.
Notice the --initial
flag. I would recommend to check the official documentation. The migrations table is used to keep track of already executed migrations. When you only run npx mikro-orm migration:create
, the table will not be created and therefore MikroORM is unable to check if the migration for the Post entity has already been performed (which includes creating the respective table on the database).
Ben does not use the --initial
flag in his tutorial, he might have already ran it prior to the tutorial.
QUESTION
ANSWER
Answered 2021-Apr-04 at 21:25You have password protected postgres instance but you are not providing the password.
QUESTION
Argument of type '{ readonly entities: readonly [typeof Post]; readonly dbName: "lireddit"; readonly type: "postgresql"; readonly debug: boolean; }' is not assignable to parameter of type 'Configuration | Options | undefined'. Type '{ readonly entities: readonly [typeof Post]; readonly dbName: "lireddit"; readonly type: "postgresql"; readonly debug: boolean; }' is not assignable to type 'Options'. Type '{ readonly entities: readonly [typeof Post]; readonly dbName: "lireddit"; readonly type: "postgresql"; readonly debug: boolean; }' is not assignable to type 'Partial>'. Types of property 'entities' are incompatible. The type 'readonly [typeof Post]' is 'readonly' and cannot be assigned to the mutable type '(string | EntityClass | EntityClassGroup | EntitySchema)[]'.ts(2345)
The index.ts: ...ANSWER
Answered 2021-Mar-27 at 11:21The way you are defining your ORM config is wrong, you should use Options
type from the core package instead of const assertion. Define the config this way to have the best intellisense support (as well as to get rid of that TS error):
QUESTION
I'm following the tutorial step by step, when I get to the part of run npx mikro-orm migration:create
, I get this error
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null
ANSWER
Answered 2020-Oct-08 at 08:14You are missing some configuration, most probably user
or password
fields. Here is related issue:
https://github.com/mikro-orm/mikro-orm/issues/866
If you do not provide them, MikroORM will pick the defaults for given driver, which is postgres
user and empty password - your postgres installation apparently do not have empty password for this user.
If you are using docker to create the postgres server, this is how you can make it accept empty pws:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lireddit
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page