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
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;








0















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.










share|improve this question




























    0















    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.










    share|improve this question
























      0












      0








      0








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 22:45









      nickjf89nickjf89

      178515




      178515






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer























          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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.






          share|improve this answer























          • 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















          0














          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.






          share|improve this answer























          • 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













          0












          0








          0







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 20:28









          Caleb KleveterCaleb Kleveter

          7,72284271




          7,72284271












          • 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

















          • 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
















          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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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
          2kmhmt7yh0D,ARgs SllV,aMAlVGpHvHn Jjq8 s3rvtD6v11

          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현