mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 20:27:49 +08:00
fix: error
This commit is contained in:
parent
30a8678036
commit
479676d678
@ -60,15 +60,19 @@ describe('sort', function () {
|
||||
const values = [
|
||||
{
|
||||
name: '1',
|
||||
__index: '0',
|
||||
children: [
|
||||
{
|
||||
name: '1-1',
|
||||
__index: '0.children.0',
|
||||
children: [
|
||||
{
|
||||
name: '1-1-1',
|
||||
__index: '0.children.0.children.0',
|
||||
children: [
|
||||
{
|
||||
name: '1-1-1-1',
|
||||
__index: '0.children.0.children.0.children.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -78,15 +82,19 @@ describe('sort', function () {
|
||||
},
|
||||
{
|
||||
name: '2',
|
||||
__index: '1',
|
||||
children: [
|
||||
{
|
||||
name: '2-1',
|
||||
__index: '1.children.0',
|
||||
children: [
|
||||
{
|
||||
name: '2-1-1',
|
||||
__index: '1.children.0.children.0',
|
||||
children: [
|
||||
{
|
||||
name: '2-1-1-1',
|
||||
__index: '1.children.0.children.0.children.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -106,10 +114,17 @@ describe('sort', function () {
|
||||
},
|
||||
tree: true,
|
||||
fields: ['id', 'name'],
|
||||
appends: ['parent', 'children'],
|
||||
sort: 'id',
|
||||
});
|
||||
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
instances.map((i) => i.toJSON()),
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
expect(instances.map((i) => i.toJSON())).toMatchObject(values);
|
||||
|
||||
const instance = await db.getRepository('categories').findOne({
|
||||
|
@ -134,7 +134,10 @@ export class Collection<
|
||||
context: options.context,
|
||||
});
|
||||
if (children?.length > 0) {
|
||||
instance.setDataValue('children', children);
|
||||
instance.setDataValue(
|
||||
'children',
|
||||
children.map((r) => r.toJSON()),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user