如何在会议室数据库查询中使用预定义的字符串?

时间:2018-11-07 13:01:01

标签: java android sqlite android-room

是否可以在“房间查询”中使用预定义的字符串?例如:

const ServicesRouting: ModuleWithProviders = RouterModule.forChild([
    {
        path: '',
        component: StructureComponent,
        canActivate: [AuthGuard],
        children: [
            {
                path: 'services',
                canActivate: [AuthGuard],
                component: servicesComponent,
                children: [
                    {
                        path: 'one',
                        canActivate: [AuthGuard],
                        component: servicesComponent,
                    },
                    {
                        path: 'two',
                        canActivate: [AuthGuard],
                        component: servicesComponent,
                    },
                    {
                        path: 'three',
                        canActivate: [AuthGuard],
                        component: servicesComponent,
                    },
                    {
                        path: 'four',
                        canActivate: [AuthGuard],
                        component: servicesComponent,
                    }
                ]
            }
        ]
    }
]);

请明确一点,我不想将其作为参数传递

@Query("delete from Bookmarks where listName != Constants.SOME_LIST_NAME")
void deleteAllBookmarks();

而且我不想对其进行硬编码(在多个地方使用过):

@Query("delete from Bookmarks where listName != :listName")
void deleteAllBookmarks(String listName);

1 个答案:

答案 0 :(得分:0)

不确定是否支持,有人可能会证明我错了,但是直到那时...你知道...

假设SOME_LIST_NAME = "MyList",则可以执行以下操作:

@Query("delete from Bookmarks where listName != MyList")
void deleteAllBookmarks();