File tree Expand file tree Collapse file tree 4 files changed +40
-15
lines changed 
controllers/security/create-user/snippets 
core-classes/user/properties Expand file tree Collapse file tree 4 files changed +40
-15
lines changed Original file line number Diff line number Diff line change @@ -6,5 +6,5 @@ template: default
66expected :
77  - " User {" 
88  - " _id: 'jdoe'," 
9-   - " content : {" 
9+   - " _source : {" 
1010  - " profileIds: \\ [ \\ 'default\\ ' \\ ]," 
Original file line number Diff line number Diff line change @@ -9,16 +9,17 @@ order: 10
99# Properties  
1010
1111
12- |  Property |  Type |  Description | 
13- | --- | --- | --- | 
14- |  ` _id `  |  <pre >string</pre > |  User ID (kuid) | 
15- |  ` content `  |  <pre >object</pre > |  User internal content | 
12+ |  Property  |  Type              |  Description                                                   | 
13+ | -----------| -------------------| ---------------------------------------------------------------| 
14+ |  ` _id `      |  <pre >string</pre > |  User ID (kuid)                                                | 
15+ |  ` _source `  |  <pre >object</pre > |  User internal content <SinceBadge  since =" auto-version " />      | 
16+ |  ` content `  |  <pre >object</pre > |  User internal content <DeprecatedBadge  since =" auto-version " /> | 
1617
17- ### content  
18+ ### _ source  
1819
19- The ` content `  property is an object containing, alongside custom defined values, the following generic properties:
20+ The ` _source `  property is an object containing, alongside custom defined values, the following generic properties:
2021
21- |  Property |  Type |  Description | 
22- | ---  | ---  | ---  | 
23- |  ` profileIds `  |  <pre >string[ ] </pre > |  Profiles IDs for this user | 
24- |  ` _kuzzle_info `  |  <pre >object</pre > |  [ Kuzzle metadata] ( /core/2/guides/main-concepts/data-storage#kuzzle-metadata )  | 
22+ |  Property        |  Type                 |  Description                                                                   | 
23+ | ---------------- | --------------------- | ------------------------------------------------------------------------------ | 
24+ |  ` profileIds `     |  <pre >string[ ] </pre > |  Profiles IDs for this user                                                    | 
25+ |  ` _kuzzle_info `  |  <pre >object</pre >    |  [ Kuzzle metadata] ( /core/2/guides/main-concepts/data-storage#kuzzle-metadata )  | 
Original file line number Diff line number Diff line change @@ -6,10 +6,20 @@ export class User {
66   * Kuid (Kuzzle unique ID) 
77   */ 
88  public  _id : string ; 
9+ 
10+   /** 
11+    * User content 
12+    */ 
13+   public  _source : JSONObject ; 
14+ 
915  /** 
10-    * Custom content 
16+    * User content 
17+    * 
18+    * @deprecated  
1119   */ 
12-   public  content : JSONObject ; 
20+   get  content  ( ) : JSONObject  { 
21+     return  this . _source ; 
22+   } 
1323
1424  private  _kuzzle : any ; 
1525
@@ -24,7 +34,7 @@ export class User {
2434    } ) ; 
2535
2636    this . _id  =  _id ; 
27-     this . content  =  content ; 
37+     this . _source  =  content ; 
2838  } 
2939
3040  private  get  kuzzle  ( )  { 
@@ -35,7 +45,7 @@ export class User {
3545   * Array of profile IDs 
3646   */ 
3747  get  profileIds  ( ) : Array < string >  { 
38-     return  this . content . profileIds  ||  [ ] ; 
48+     return  this . _source . profileIds  ||  [ ] ; 
3949  } 
4050
4151  /** 
Original file line number Diff line number Diff line change @@ -41,4 +41,18 @@ describe('User', () => {
4141        } ) ; 
4242    } ) ; 
4343  } ) ; 
44+ 
45+   describe ( '#_source' ,  ( )  =>  { 
46+     it ( 'should return the user custom content' ,  ( )  =>  { 
47+       user  =  new  User ( { } ,  'foobar' ,  {  email : 'foobar@goo.com'  } ) ; 
48+ 
49+       should ( user . _source ) . be . eql ( {  email : 'foobar@goo.com'  } ) ; 
50+     } ) ; 
51+ 
52+     it ( 'should keep accessors to deprecated "content" getter' ,  ( )  =>  { 
53+       user  =  new  User ( { } ,  'foobar' ,  {  email : 'foobar@goo.com'  } ) ; 
54+ 
55+       should ( user . content ) . be . eql ( {  email : 'foobar@goo.com'  } ) ; 
56+     } ) ; 
57+   } ) ; 
4458} ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments