Tsed: PropertyType & Property Name issue

Created on 8 Jul 2018  路  10Comments  路  Source: tsedio/tsed

Hello!

I have an issue with converting _id into id for models which are used for PropertyType, for example:

export class AdminModel {

    @Property({ name: 'id' }) // this one looks like _id in response, but it should be just id
    _id: string;

    @Ref(UserModel)
    user: Ref<UserModel>;

    @Property()
    role: string;

}

@Model({
    name: 'Service'
})
export class ServiceModel implements IServiceModel {

    @Property({ name: 'id' }) // this one works as expected and turns into id
    _id: string;

    @PropertyType(AdminModel)
    admins: AdminModel[];

}

Version: 4.23.0

Btw i tried to upgrade to the latest (4.26.3) to check if it's already fixed, but have the error related to SocketIO:

[1] [2018-07-08T01:41:21.447] [ERROR] [TSED] - { Error: Cannot find module '../../common/config/decorators/constant'
[1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
[1]     at Module.require (internal/modules/cjs/loader.js:598:17)
[1]     at require (internal/modules/cjs/helpers.js:11:18)
[1]     at Object.<anonymous> (/var/www/backend/node_modules/@tsed/src/socketio/services/SocketIOService.ts:15:1)
[1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)

Thanks in advance and thanks for the time you spend to work on TsED. This project is amazing.

In progress bug enhancement

All 10 comments

Hi @RevanScript,

Thanks for the issue :)

The bad import in socketio is fixed. I'll investigate on your first bug ;)

See you
Romain

Found and fixed :)

Thanks a lot! Works fine now

Not yet. Looks like it gave rise to another bug :)
All @Ref which weren't populated return object now:

    @Ref(ItemCategoryModel)
    category: Ref<ItemCategoryModel>;

Returns:

    "category": {
        "id": "5b28784ea63afa026a88d8be"
    },

Expected just "category": "5b28784ea63afa026a88d8be" if .populate('category') wasn't used.

Arg, it's very specific from Mongoose... I need to find another solution because, the latest fix break something too.

Any updates on this? :)

Hello @RevanScript ,

No update, sorry... unfortunately, this problem is a bit complex and is related on other issues based on JsonSchema and ConverterService.

I've already tried to fix your problem but it has introduce regression on other features.

I've a lot of bug/enhancement in the backlog, this one is prioritized on top of the list, but it require more than one day to work on T.T
Sorry for the long time to fix that.

I'll try to focus my effort on this part ASAP.
Romain

Ok, no problem. I just asked to decide if i should wait or use a workaround until it's fixed.
Thanks for the answer and your work!

I think, it would be better to work on workaround, share your works with me ;)

v6 fix this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haroon407 picture haroon407  路  4Comments

teusemanuel picture teusemanuel  路  4Comments

Ionaru picture Ionaru  路  5Comments

royibernthal picture royibernthal  路  4Comments

RickStanley picture RickStanley  路  6Comments