many-to-many

How to query all subdocuments

只谈情不闲聊 提交于 2019-12-20 21:02:13
问题 I'm beginning with MongoDb and nodejs (using mongoose). I have a collection of Stories , each of them can have one or more Tags , it's something like that: { title: "The red fox", content: "The red fox jumps away...", tags: [ { tagname: "fairytale", user: "pippo" }, { tagname: "funny", user: "pluto" }, { tagname: "fox", user: "paperino" } ] }, ... other stories Now I want to make a tag cloud . It means querying Stories for all tags. In a relational world (e.g. MySQL) I would have a Stories

How to query all subdocuments

我的梦境 提交于 2019-12-20 21:02:03
问题 I'm beginning with MongoDb and nodejs (using mongoose). I have a collection of Stories , each of them can have one or more Tags , it's something like that: { title: "The red fox", content: "The red fox jumps away...", tags: [ { tagname: "fairytale", user: "pippo" }, { tagname: "funny", user: "pluto" }, { tagname: "fox", user: "paperino" } ] }, ... other stories Now I want to make a tag cloud . It means querying Stories for all tags. In a relational world (e.g. MySQL) I would have a Stories

What is the proper way to deal with adding/deleting many-to-many relationships in REST?

筅森魡賤 提交于 2019-12-20 18:05:57
问题 Let's say we have an entity that contains a list of users on the server, and we want to expose this as rest. What is the proper way to do it? My first guess is something like this: /entity/1/user/5 We can use PUT for updates and DELETE for deletes? Is this right? I went to wikipedia where it talks about rest, and their view of it is that everything is only 1 level deep. So maybe they want you to use PUT/POST and give the entire JSON graph and update the entire thing all at once? 回答1: Your

What is the proper way to deal with adding/deleting many-to-many relationships in REST?

末鹿安然 提交于 2019-12-20 18:05:05
问题 Let's say we have an entity that contains a list of users on the server, and we want to expose this as rest. What is the proper way to do it? My first guess is something like this: /entity/1/user/5 We can use PUT for updates and DELETE for deletes? Is this right? I went to wikipedia where it talks about rest, and their view of it is that everything is only 1 level deep. So maybe they want you to use PUT/POST and give the entire JSON graph and update the entire thing all at once? 回答1: Your

How to dynamically order many-to-many relationship with JPA or HQL?

被刻印的时光 ゝ 提交于 2019-12-20 14:15:36
问题 I have a mapping like this: @ManyToMany(cascade = CascadeType.PERSIST) @JoinTable( name="product_product_catalog", joinColumns={@JoinColumn(name="product_catalog", referencedColumnName="product_catalog")}, inverseJoinColumns={@JoinColumn(name="product", referencedColumnName="product")}) public List<Product> products = new ArrayList<Product>(); I can fetch the products for the catalog nicely, but I can't (dynamically) order the products. How could I order them? I probably have to write a many

How to update/create many-to-many relational data in MVC Code-first using EF?

流过昼夜 提交于 2019-12-20 10:47:33
问题 I have pored through StackOverflow, Google and asp.net trying to find a clear cut, basic example of how to do this. All the examples have been abstract or involved complications that do not apply. I haven't been able to extract much useful from them. So far, none of them have completely answered my question or addressed my issue(s). I am working on an MVC project with the following model: Article.cs: public class Article { public int ArticleId { get; set; } public string Title { get; set; } .

Linq2Sql Many:Many question, How would you do this?

可紊 提交于 2019-12-20 10:13:21
问题 I know many:many isn't supported in Linq2Sql but I am working on a workaround I am working with my little SO clone and I have a table with Questions and a table with Tags and a linking table QuestionTag so I have a classic many:many relationship between Questions and Tags. To display the list of Questions on the front page I have this class I want to fill up from a Linq2Sql query public class ListQuestion { public int QuestionID { get; set; } public string Title{ get; set; } public

Hibernate: delete many-to-many association

筅森魡賤 提交于 2019-12-20 10:04:40
问题 I have two tables with the many-to-many association. — DB fragment: loads Id Name sessions Id Date sessionsloads LoadId SessionId — Hibernate mapping fragments: /* loads.hbm.xml */ <set name="sessions" table="sessionsloads" inverse="true"> <key column="LoadId" /> <many-to-many column="SessionId" class="Session" /> </set> … /* sessions.hbm.xml */ <set name="loads" table="sessionsloads"> <key column="SessionId" /> <many-to-many column="LoadId" class="Load" /> </set> In order to remove one entry

Saving many-to-many relationship in Entity Framework Core

时光怂恿深爱的人放手 提交于 2019-12-20 08:39:42
问题 For example, I have 3 classes, which I'm using for many-to-many relationship: public class Library { [Key] public string LibraryId { get; set; } public List<Library2Book> Library2Books { get; set; } } public class Book { [Key] public string BookId { get; set; } public List<Library2Book> Library2Books { get; set; } } public class Library2Book { public string BookId { get; set; } public Book Book { get; set; } public string LibraryId { get; set; } public Library Library { get; set; } } They're

ManyToMany relationship with extra fields in symfony2 orm doctrine

百般思念 提交于 2019-12-20 06:45:39
问题 Hi i have that same question as here: Many-to-many self relation with extra fields? but i cant find an answer :/ I tried first ManyToOne and at the other site OneToMany ... but then i could not use something like public function hasFriend(User $user) { return $this->myFriends->contains($user); } because there was some this problem: This function is called, taking a User type $user variable and you then use the contains() function on $this->myFriends. $this->myFriends is an ArrayCollection of