поменял конфиг, мелкие правки
This commit is contained in:
parent
89f64aae98
commit
4884016a3e
@ -1,4 +1,4 @@
|
|||||||
import { List, Datagrid, TextField, EditButton } from "react-admin";
|
import { List, Datagrid, TextField, EditButton, ReferenceField } from "react-admin";
|
||||||
|
|
||||||
function UsersList() {
|
function UsersList() {
|
||||||
return (
|
return (
|
||||||
@ -8,6 +8,9 @@ function UsersList() {
|
|||||||
<TextField source="nickname" />
|
<TextField source="nickname" />
|
||||||
<TextField source="email" />
|
<TextField source="email" />
|
||||||
<TextField source="avatar" />
|
<TextField source="avatar" />
|
||||||
|
<ReferenceField label="Role" source="role_id" reference="roles">
|
||||||
|
<TextField source="name" />
|
||||||
|
</ReferenceField>
|
||||||
<EditButton />
|
<EditButton />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
</List>
|
</List>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
PORT=5000
|
PORT=5000
|
||||||
DB_NAME=test_db
|
DB_NAME=subd_db
|
||||||
DB_USER=postgres
|
DB_USER=postgres
|
||||||
DB_PASSWORD=postgres
|
DB_PASSWORD=postgres
|
||||||
DB_HOST=localhost
|
DB_HOST=192.168.56.101
|
||||||
DB_PORT=5433
|
DB_PORT=5432
|
@ -19,13 +19,13 @@ class MessageController {
|
|||||||
? JSON.parse(req.query.sort.toString())
|
? JSON.parse(req.query.sort.toString())
|
||||||
: ["id", "ASC"];
|
: ["id", "ASC"];
|
||||||
|
|
||||||
const Messages = await Message.findAndCountAll({
|
const messages = await Message.findAndCountAll({
|
||||||
offset: range[0],
|
offset: range[0],
|
||||||
limit: range[1] - range[0] + 1,
|
limit: range[1] - range[0] + 1,
|
||||||
order: [sort] as Order
|
order: [sort] as Order
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.json({ data: Messages.rows, total: Messages.count });
|
return res.json({ data: messages.rows, total: messages.count });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(ApiErrorHandler.internal((error as Error).message));
|
next(ApiErrorHandler.internal((error as Error).message));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { sequelize } from './db.js';
|
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
|
import { sequelize } from "./db.js";
|
||||||
import { router } from "./routes/routes.ts";
|
import { router } from "./routes/routes.ts";
|
||||||
import { ErrorHandlingMiddleware } from "./middleware/error-handling.middleware.ts";
|
import { ErrorHandlingMiddleware } from "./middleware/error-handling.middleware.ts";
|
||||||
|
|
||||||
@ -23,6 +23,6 @@ const start = async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
@ -4,8 +4,6 @@ import {
|
|||||||
Model,
|
Model,
|
||||||
DataType,
|
DataType,
|
||||||
Length,
|
Length,
|
||||||
UpdatedAt,
|
|
||||||
CreatedAt,
|
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
BelongsTo
|
BelongsTo
|
||||||
} from "sequelize-typescript";
|
} from "sequelize-typescript";
|
||||||
@ -13,7 +11,7 @@ import User from "./user.model";
|
|||||||
import Thread from "./thread.model";
|
import Thread from "./thread.model";
|
||||||
|
|
||||||
@Table({
|
@Table({
|
||||||
timestamps: true,
|
timestamps: false,
|
||||||
tableName: "messages",
|
tableName: "messages",
|
||||||
modelName: "Message"
|
modelName: "Message"
|
||||||
})
|
})
|
||||||
@ -33,12 +31,6 @@ export default class Message extends Model {
|
|||||||
})
|
})
|
||||||
declare text: string;
|
declare text: string;
|
||||||
|
|
||||||
@CreatedAt
|
|
||||||
declare created_at: Date;
|
|
||||||
|
|
||||||
@UpdatedAt
|
|
||||||
declare updated_at: Date;
|
|
||||||
|
|
||||||
@ForeignKey(() => User)
|
@ForeignKey(() => User)
|
||||||
@Column({
|
@Column({
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user