How to create a unique constraints in YML in Doctrine2? - doctrine-orm

I Want to create a unique constraints on two attributs. The YML configuration with Doctrine2 isn't well documented. So I try to traduct the XML in YML. What's wrong with this code?
unique-constraints:
name: event_user
columns:
event_id: ~
user_id: ~
Thanks in advance.

Finally I managed to create it by this code:
uniqueConstraints:
event_user_idx:
columns: event_id,user_id
But Thank Reuven for your answer.

You should try that:
uniqueConstraints:
event_user:
columns:
- event_id
- user_id

I don't know if this part of the documentation has been added recently or not, but here is what it says:
# ECommerceProduct.orm.yml
ECommerceProduct:
type: entity
fields:
# definition of some fields
uniqueConstraints:
search_idx:
columns: [ name, email ]

Related

How to customize field representation in django drf AutoSchema?

I am new to using Django drf schema generation. I installed and configured the schema according to the documentation. It generates the OpenAPI schema. Now I want to customize the choice field representation and add some description in front of each field.
Current schema choice field is like below:
condition:
enum:
- used
- new
- like new
type: string
nullable: true
I want the following:
condition:
enum:
- used: "for used items"
- new: "for new items"
- like new: " brand new items"
type: string
nullable: true
In the documentation I could find little on how to customize the AutoSchema class but that was above my knowledge. I would be grateful if someone can help me on how can I override the schema methods to represent customize fields?

Tiddlywiki: Configure '$:/config/FileSystemPaths' to save to a folder based on a field

I have a TiddlyWiki where the tiddlers have a field "saveto". I want to add a line to the file '$:/config/FileSystemPaths' to prefix the name of the tiddler with the value of the "saveto" field. For example, the tiddler
created: 20200114160408003
modified: 20200114160440095
saveto: test
tags:
title: New Tiddler
type: text/vnd.tiddlywiki
should be saved at test/New Tiddler.tid
Is it possible? I don't know much about filters, these are some things I have tried:
[has[saveto]addprefix[get[saveto]]]
[has[saveto]addprefix:get[saveto]]
[has[saveto]addprefix{!!saveto}]
Thanks for any help!
Here is something that works:
[has[saveto]get[saveto]] [get[title]] +[join[/]]
This solution was created by Jeremy Ruston as an answer to my post on the Tiddlywiki google groups forum

What is the contain method in Django rest_framework Filter

Let's say I have a database that looks like this:
{
name: 'We love Football',
type: 'Sports',
}
{
name: 'Let's play Football',
type: 'Sports'
}
{
name: 'Let's play Basketball',
type: 'Sports'
}
I need to implement something like this:
class GameAPIListView(ListAPIView):
serializer_class = GameSerializer
def get_queryset(self):
term = self.request.GET['term']
data = Game.objects.filter(name.contains(term))
return data
If I type "Fooball", the first two items will be returned, since they contain the token "Football". What is the correct way to do this? Thanks in advance.
You need to try with name__contains link. another thing is to search with icontains link for case insensitive search.
Also if you are using postgres database there are so many additional search features link
available in django.

Using a regex in the custom field of Filebeat

Here I can read that when configuring a prospect I can add a custom field to the data, which later I can use for filtering.
So for example I can write
- type: log
paths:
- /my/path/app1.csv
fields:
app_name: app1
- type: log
paths:
- /my/path/app2.csv
fields:
app_name: app2
This means that anytime I will have a new CSV file to track I have to add it to the filebeat.yml file adding the custom app_name field accordingly.
I was wondering if I could use a regex with a capture group in the prospect definition to "automatically" track any new file and assign the right app_name value. Something like this:
- type: log
paths:
- /my/path/(.*).csv
fields:
app_name: \1
What do you think? I didn't find any documentation regarding this possibility with the fields feature.
As adviced here, I can use the source Filebeat field to filter the data. This field is the path of the harvested files, so no other field is required to filter.

Ember-Data: Ember does not make the connection between two related models - DS.ActiveModelAdapter

I am trying to retrieve a project which has a hasMany relationship to projectTeams which has a belongsTo relationship to Teams.
I am using ActiveModelAdapter and have followed the conventions indicated in the doc on emberjs.com. After the files have been retrieved, I checked the JSON output and it is valid according to what ember expects (foreign keys contain the _id suffix). However, the relationship between the models is not made.
Interesting fact though is that I can get a reference from ProjectTeam to both Project and Team...
For your convenience I created the following fiddle:
http://jsfiddle.net/alexspeller/SwWkB/1/
You need to define the project team ids on the json for projects
id: 1
name: "asd"
top_down_date: "2014-01-08"
cape_town_date: "2014-01-23"
created_at: "2014-01-04T16:17:59.441Z"
updated_at: "2014-01-04T16:17:59.441Z"
project_team_ids: [1]
http://jsfiddle.net/VHfKv/