fix empty object
This commit is contained in:
@ -30,7 +30,7 @@ export class Store extends Document {
|
||||
|
||||
@Prop({
|
||||
required: true,
|
||||
type: {}
|
||||
type: Object,
|
||||
})
|
||||
value: any;
|
||||
|
||||
|
||||
@ -30,7 +30,11 @@ export class StoreService {
|
||||
|
||||
await validateModel(createdStore);
|
||||
|
||||
return createdStore.save();
|
||||
const savedStore = await createdStore.save();
|
||||
if (!Object.keys(savedStore.value).length) {
|
||||
await savedStore.updateOne(store);
|
||||
}
|
||||
return savedStore;
|
||||
}
|
||||
|
||||
async update({author, ...omitProps}: StoreRequest): Promise<Store> {
|
||||
|
||||
14
store.http
14
store.http
@ -2,7 +2,7 @@ GET http://localhost:4001/store HTTP/1.1
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:4001/store/testApi HTTP/1.1
|
||||
GET http://localhost:4001/store/testApi22 HTTP/1.1
|
||||
|
||||
###
|
||||
|
||||
@ -10,10 +10,9 @@ POST http://localhost:4001/store HTTP/1.1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"key": "testApi",
|
||||
"key": "testApi-4",
|
||||
"value": {
|
||||
"name": "ivan",
|
||||
"age": 16
|
||||
|
||||
},
|
||||
"description": "тестовое апи",
|
||||
"service_name": "test-api",
|
||||
@ -26,10 +25,9 @@ PUT http://localhost:4001/store HTTP/1.1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"key": "testApi",
|
||||
"key": "testApi-4",
|
||||
"value": {
|
||||
"name": "ivan23",
|
||||
"age": 22
|
||||
|
||||
},
|
||||
"description": "тестовое апи",
|
||||
"service_name": "test-api",
|
||||
@ -38,4 +36,4 @@ content-type: application/json
|
||||
|
||||
###
|
||||
|
||||
DELETE http://localhost:4001/store/testApi HTTP/1.1
|
||||
DELETE http://localhost:4001/store/testApi22 HTTP/1.1
|
||||
Reference in New Issue
Block a user