Question: I am new to Sails and facing a small issue with models.  

I have defined a user model as follows: 

```
module.exports = {  
  attributes: {
   firstName: {
     type: 'string'
   },
   lastName: {
      type: 'string'
   },
   email: {
     type: 'email',
     required: true
   },

   password: {
     type: 'String'
   },
   passwordSalt: {
     type: 'String'
   },
   projects:{
     collection: 'ProjectMember',
     via: 'userId'
   }
 }
};  

```

I have one more model called Plan which has user as its foreign key: 

```
module.exports = {
   planId: { type: 'string'},
   userId: { model: 'User'}
};  

```

Now Plan stores all user data. Is there any way I can restrict Plan model to hold only some of User details like firstName, lastName, email and projectMembers instead of storing other personal info. like password, passwordSalt, etc? 

Thanks In Advance

Answer: 
Overriding `Equals` in this situation seems a little overkill here, why not just do

```
currentPerson.Vessels.Any(x => x.ID == currentVessel.ID)

```
The solution suggested by @james is not the best practice. 
here why if you have a long list of Vessels that should be added to a `Hashset<Vessel>` contains method will cost only `O(1)` since it will be indexed on `GetHashCode` while `.Any` is an extension method that should iterate through all elements to find the right one and the cost will be `O(n)` 

you could do something like this 

```
public class Vessel : IEquatable<Vessel>
    {
        public int Id { get; set; }

        public bool Equals(Vessel other)
        {
            return Id == other.Id ; 
        }

        public override int GetHashCode()
        {
            return Id;
        }
        public override bool Equals(object obj)
        {
            var vessel = obj as Vessel;
            return vessel != null && vessel.Id == this.Id;
        }
    }

```

**Update** 

the reasons why I have stated it's not a best practice it's that OP stated that he has an `ICollection<Vessel>` which can be converted to many Generics collections like `List<T>` for example. 

from [`MSDN`](http://msdn.microsoft.com/en-us/library/ms131190(v=vs.110).aspx) 

When the search methods of a number of generic collection objects are called. Some of these types and their methods include the following:

* Some of the generic overloads of the BinarySearch method.
* The search methods of the List class, including List.Contains(T), List.IndexOf, List.LastIndexOf, and List.Remove.
* The search methods of the Dictionary class, including ContainsKey and Remove.
The search methods of the generic LinkedList class, including LinkedList.Contains and Remove.