json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Expand/Embed multiple levels of ancestors/descendants

Open zeralight opened this issue 5 years ago • 2 comments

Hello,

Is it possible to expand multiple levels of the parents / children (parent of the parent, etc.) For example, for the following db.json:

{
	"users": [
		{
			"id": 1,
			"name": "a"
		},
		{
			"id": 2,
			"name": "b"
		},
		{
			"id": 1,
			"name": "c"
		},
		{
			"id": 1,
			"name": "d"
		}
	],
	"posts": [
		{
			"id": 1,
			"title": "post1",
			"userId": 1
		},
		{
			"id": 2,
			"title": "post2",
			"userId": 1
		},
		{
			"id": 3,
			"title": "post3",
			"userId": 2
		},
		{
			"id": 4,
			"title": "post4",
			"userId": 2
		}
	],
	"sections": [
		{
			"id": 1,
			"postId": 1
		},
		{
			"id": 2,
			"postId": 1
		},
		{
			"id": 3,
			"postId": 1
		},
		{
			"id": 4,
			"postId": 2
		},
		{
			"id": 1,
			"postId": 2
		}
	]
}

Would it be possible to run /sections?_expand=post&_expand=user&userId=1 to get


{
	"id": 1,
	"postId": 1,
	"post": 
	{
		"id": 1,
		"title": "post1",
		"userId": 1,
		"user":
		{
			"id": 1,
			"name": "a"
		}
	}
}

zeralight avatar Mar 06 '20 00:03 zeralight

I am in this situation too.

ko25july avatar Oct 26 '20 06:10 ko25july

Any update?

xumeng avatar Sep 23 '22 02:09 xumeng

same here, I thought that &_expand=entity&_expand=entity.entityStatus might work, but didn't

kuncevic avatar Apr 02 '23 05:04 kuncevic