Return partial object in Vapor 3How to call Objective-C code from SwiftIs there any way to work with real Object in Graph Library for core dataSetting up Vapor and Vapor-MySQLLookup key inside array of object in FirebaseForm Input with dynamic return typeAccess a child key:value for a user in Firebase - SwiftIs it good practice to wrap related set of properties into its own struct/class?How to build vapor toolbox with vapor 3.xCreating and returning database records with VaporReturning a JSON containing an array in Vapor
Multi tool use
What happens if you dump antimatter into a black hole?
Can my company stop me from working overtime?
Why do we use hermite interpolation for finite element method in beams?
Why Isn’t SQL More Refactorable?
What was the first instance of a "planet eater" in sci-fi?
Are there any Final Fantasy Spirits in Super Smash Bros Ultimate?
Can you complete the sequence?
Will 700 more planes a day fly because of the Heathrow expansion?
BOOM! Perfect Clear for Mr. T
How do I overfit?
Verb "geeitet" in an old scientific text
String won't reverse using reverse_copy
Would Hubble Space Telescope improve black hole image observed by EHT if it joined array of telesopes?
Purpose of のは in this sentence?
Pressure inside an infinite ocean?
How can I get a job without pushing my family's income into a higher tax bracket?
Why do money exchangers give different rates to different bills?
What is the closest airport to the center of the city it serves?
What was the design of the Macintosh II's MMU replacement?
What are the differences between credential stuffing and password spraying?
Getting a W on your transcript for grad school applications
Expressing 'our' for objects belonging to our apartment
What is the difference between 反日 and 日本たたき?
Does a card have a keyword if it has the same effect as said keyword?
Return partial object in Vapor 3
How to call Objective-C code from SwiftIs there any way to work with real Object in Graph Library for core dataSetting up Vapor and Vapor-MySQLLookup key inside array of object in FirebaseForm Input with dynamic return typeAccess a child key:value for a user in Firebase - SwiftIs it good practice to wrap related set of properties into its own struct/class?How to build vapor toolbox with vapor 3.xCreating and returning database records with VaporReturning a JSON containing an array in Vapor
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I would like to return a partial object in a response for another object type.
For example, I have a UserProfile model:
var id: Int?
var email: String
var firstName: String?
var lastName: String?
and an Adult model:
var id: Int?
var nickname: String
var type: String
var user: User.UserProfile
var family: Family
Say I would like to return just the UserProfile's email address in the Adult response, what is the way to go about that?
I have tried an approach with child/parent relationships, where my Adult model is more like:
var id: Int?
var nickname: String
var type: String
var user: User.ID
var family: Family
..but then my response just contains an object ID, but I really want to return a partial (or even full in some cases) object.
Thanks in advance.
swift vapor
add a comment |
I would like to return a partial object in a response for another object type.
For example, I have a UserProfile model:
var id: Int?
var email: String
var firstName: String?
var lastName: String?
and an Adult model:
var id: Int?
var nickname: String
var type: String
var user: User.UserProfile
var family: Family
Say I would like to return just the UserProfile's email address in the Adult response, what is the way to go about that?
I have tried an approach with child/parent relationships, where my Adult model is more like:
var id: Int?
var nickname: String
var type: String
var user: User.ID
var family: Family
..but then my response just contains an object ID, but I really want to return a partial (or even full in some cases) object.
Thanks in advance.
swift vapor
add a comment |
I would like to return a partial object in a response for another object type.
For example, I have a UserProfile model:
var id: Int?
var email: String
var firstName: String?
var lastName: String?
and an Adult model:
var id: Int?
var nickname: String
var type: String
var user: User.UserProfile
var family: Family
Say I would like to return just the UserProfile's email address in the Adult response, what is the way to go about that?
I have tried an approach with child/parent relationships, where my Adult model is more like:
var id: Int?
var nickname: String
var type: String
var user: User.ID
var family: Family
..but then my response just contains an object ID, but I really want to return a partial (or even full in some cases) object.
Thanks in advance.
swift vapor
I would like to return a partial object in a response for another object type.
For example, I have a UserProfile model:
var id: Int?
var email: String
var firstName: String?
var lastName: String?
and an Adult model:
var id: Int?
var nickname: String
var type: String
var user: User.UserProfile
var family: Family
Say I would like to return just the UserProfile's email address in the Adult response, what is the way to go about that?
I have tried an approach with child/parent relationships, where my Adult model is more like:
var id: Int?
var nickname: String
var type: String
var user: User.ID
var family: Family
..but then my response just contains an object ID, but I really want to return a partial (or even full in some cases) object.
Thanks in advance.
swift vapor
swift vapor
asked Mar 22 at 22:45
nickjf89nickjf89
178515
178515
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The way this is done is to create a 'public' definition of your model, which will represent the JSON you return from your route.
For your model, you might create a struct like this:
struct AdultResponse: Content
var id: Int?
var nickname: String
var type: String
var email: String
var family: Family
init(adult: Adult)
self.id = adult.id
self.nickname = adult.nickname
self.type = adult.type
self.email = adult.user.email
self.family = adult.family
You can then get your Adult
model from the database, create an AdultResponse
and return that from your route.
Thanks. However whenever I declare a struct with a property of typeFamily
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.
– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308735%2freturn-partial-object-in-vapor-3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The way this is done is to create a 'public' definition of your model, which will represent the JSON you return from your route.
For your model, you might create a struct like this:
struct AdultResponse: Content
var id: Int?
var nickname: String
var type: String
var email: String
var family: Family
init(adult: Adult)
self.id = adult.id
self.nickname = adult.nickname
self.type = adult.type
self.email = adult.user.email
self.family = adult.family
You can then get your Adult
model from the database, create an AdultResponse
and return that from your route.
Thanks. However whenever I declare a struct with a property of typeFamily
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.
– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
add a comment |
The way this is done is to create a 'public' definition of your model, which will represent the JSON you return from your route.
For your model, you might create a struct like this:
struct AdultResponse: Content
var id: Int?
var nickname: String
var type: String
var email: String
var family: Family
init(adult: Adult)
self.id = adult.id
self.nickname = adult.nickname
self.type = adult.type
self.email = adult.user.email
self.family = adult.family
You can then get your Adult
model from the database, create an AdultResponse
and return that from your route.
Thanks. However whenever I declare a struct with a property of typeFamily
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.
– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
add a comment |
The way this is done is to create a 'public' definition of your model, which will represent the JSON you return from your route.
For your model, you might create a struct like this:
struct AdultResponse: Content
var id: Int?
var nickname: String
var type: String
var email: String
var family: Family
init(adult: Adult)
self.id = adult.id
self.nickname = adult.nickname
self.type = adult.type
self.email = adult.user.email
self.family = adult.family
You can then get your Adult
model from the database, create an AdultResponse
and return that from your route.
The way this is done is to create a 'public' definition of your model, which will represent the JSON you return from your route.
For your model, you might create a struct like this:
struct AdultResponse: Content
var id: Int?
var nickname: String
var type: String
var email: String
var family: Family
init(adult: Adult)
self.id = adult.id
self.nickname = adult.nickname
self.type = adult.type
self.email = adult.user.email
self.family = adult.family
You can then get your Adult
model from the database, create an AdultResponse
and return that from your route.
answered Mar 23 at 20:28
Caleb KleveterCaleb Kleveter
7,72284271
7,72284271
Thanks. However whenever I declare a struct with a property of typeFamily
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.
– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
add a comment |
Thanks. However whenever I declare a struct with a property of typeFamily
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.
– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
Thanks. However whenever I declare a struct with a property of type
Family
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.– nickjf89
Mar 23 at 22:37
Thanks. However whenever I declare a struct with a property of type
Family
for example, I get back the error "operator does not exist: jsonb = bigint" in the response.– nickjf89
Mar 23 at 22:37
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
@nickjf89 Hmm, not really sure what would cause that. Maybe someone on the Discord chat could help.
– Caleb Kleveter
Mar 23 at 23:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308735%2freturn-partial-object-in-vapor-3%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
QX7Cv aaakFoBjDC,9EOJfwBIOyG J32Pq,zA8LL1bIaliR9mz