title: How to update many to many relationship by using id with sqlalchemy?
body: <p>I know I can simply update many to many relationship like this:</p>
  
  <pre><code>tags = db.Table('tags',
      db.Column('tag_id', db.Integer, db.ForeignKey('tag.id'), primary_key=True),
      db.Column('page_id', db.Integer, db.ForeignKey('page.id'), primary_key=True)
  )
  
  class Page(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      tags = db.relationship('Tag', secondary=tags, lazy='subquery',
          backref=db.backref('pages', lazy=True))
  
  class Tag(db.Model):
      id = db.Column(db.Integer, primary_key=True)
  
  tag1 = Tag()
  tag2 = Tag()
  page = Page( tags=[tag1])
  </code></pre>
  
  <p>and later for updating:</p>
  
  <pre><code>
  page.append(tag2)
  
  </code></pre>
  
  <p>but I want to update them only by the tag id, Assume I have to create a general function that only accepts <code>person</code> and <code>id</code>s for addresses and update it. 
  What I want is something like this:</p>
  
  <pre><code>page = Page(tags=[1,2]) # 1 and 2 are primary keys of (tag)s
  </code></pre>
  
  <p>or in a function</p>
  
  <pre><code>def update_with_foreignkey(page, tags=[1,2]):
   # dosomething to update page without using Tag object
   return  updated page
  </code></pre>