Documents with same Raven-Entity-Name not grouped into collection - ravendb

I've got this weird situtation with Ravendb collections.
Saved two documents with exactly the same metadata:
Documents:
{
"Title": "Some title",
"ProductType": "Some type",
"Description": "Some description",
"Keywords": "Some keywords"
}
Metadata:
{
"Raven-Entity-Name": "MetaDatas",
"Raven-Clr-Type": "DomainModel.MetaData, DomainModel"
}
The ravendb studio won't show them into one collection and loading/querying the documents via C# code gives me always null as result:
var metaData = Session.Query<MetaData>().SingleOrDefault(m => m.ProductType == productType);
and
var metaData = Session.Load<MetaData>("MetaDatas-1");

Related

Zephyr for Jira Create test using API

my goal is to create a test in Zephyr for Jira using API. I found something like this on the internet
"fields": {
"issuetype": {
"name": "Test"
},
"project":
{
"key": "TP"
},
"summary": "Test From API",
"description": "",
"assignee": {
"name": "Some Name"
},
"customfield_10014": "SOMEKEY",
"duedate": "2018-10-03",
"priority": {
"name": "Medium"
},
"labels": ["label1", "label2"],
"customfield_19416": "50h",
"customfield_19719": {
"value": "minor"
},
"customfield_11101": [
{
"Test Step": "some text",
"Test Data": "some text",
"Test Result": "some text"
},
{
"Test Step": "some text",
"Test Data": "some text",
"Test Result": "some text"
},
{
"Test Step": "some text",
"Test Data": "some text",
"Test Result": "some text"
}
]
}
I have really no idea what API should I use.
Recently I was able to create test cycle using the following API
https://prod-api.zephyr4jiracloud.com/connect/public/rest/api/1.0/cycle
which can be found on this page
https://zfjcloud.docs.apiary.io/#reference/cycle
Unfortunately I can't find similar API for test creation. Is it possible?
PS: I am using Authorization, Content-Type, zapiAccessKey headers, where Authorization is JWT key
Thanks for the tips
Create an issue in JIRA via the API's. Select the issue type as Test.
https://support.smartbear.com/zephyr-squad-server/docs/api/how-to/create-tests.html
POST /rest/api/2/issue
The above request will give you an ID that is internal to JIRA. Not the one that gets displayed in UI for any Issue/ticket that is created.
Extract this ID field and then
Create the test steps.
https://support.smartbear.com/zephyr-squad-server/docs/api/how-to/add-steps-to-tests.html
POST /rest/zapi/latest/teststep/{issueId}
I don't want to echo the contents on smartbear website.
Hence, this high level workflow solution for your implementation.

GraphQL query - Query by ID

I have installed the strapi-starter-blog locally and I'm trying to understand how I can query article by ID (or slug). When I open the GraphQL Playground, I can get all the article using:
query Articles {
articles {
id
title
content
image {
url
}
category {
name
}
}
}
The response is:
{
"data": {
"articles": [
{
"id": "1",
"title": "Thanks for giving this Starter a try!",
"content": "\n# Thanks\n\nWe hope that this starter will make you want to discover Strapi in more details.\n\n## Features\n\n- 2 Content types: Article, Category\n- Permissions set to 'true' for article and category\n- 2 Created Articles\n- 3 Created categories\n- Responsive design using UIkit\n\n## Pages\n\n- \"/\" display every articles\n- \"/article/:id\" display one article\n- \"/category/:id\" display articles depending on the category",
"image": {
"url": "/uploads/blog_header_network_7858ad4701.jpg"
},
"category": {
"name": "news"
}
},
{
"id": "2",
"title": "Enjoy!",
"content": "Have fun!",
"image": {
"url": "/uploads/blog_header_balloon_32675098cf.jpg"
},
"category": {
"name": "trends"
}
}
]
}
}
But when I try to get the article using the ID with variable, like here github code in the GraphQL Playground with the following
Query:
query Articles($id: ID!) {
articles(id: $id) {
id
title
content
image {
url
}
category {
name
}
}
}
Variables:
{
"id": 1
}
I get an error:
...
"message": "Unknown argument \"id\" on field \"articles\" of type \"Query\"."
...
What is the difference and why can't I get the data like in the example of the Github repo.
Thanks for your help.
It's the difference between articles and article as the query. If you use the singular one you can use the ID as argument

Add new properties to DocumentDB Document in Stored procedure

I have a JSON document which I am passing to DocumentDB stored procedure. Is there a way I can add more properties to document in store procedure
Passed to DocumentDB:
{
"id": "Authentication",
"name": "All users must be authenticated before being authorized for any access to service data",
"type": "Control"
}
Expected changes in Stored Procedure:
{
"id": "Authentication",
"accountId": "Test",
"versions": [
"name": "All users must be authenticated before being authorized for any access to service data",
"type": "Control",
"tags": [],
"links": []
]
}
You can manipulate the object (add / remove properties) using plain JavaScript syntax.
And then use the DocumentDB server-side JavaScript SDK to create the document.
Here's an example Stored Procedure to get you started:
function transform(doc) {
var collection = getContext().getCollection();
var response = getContext().getResponse();
// Add new accountId and versions fields.
doc.accountId = "Test";
doc.versions = {
name: doc.name,
type: doc.type,
tags: [],
links: []
};
// Remove old name and type fields.
delete doc.name;
delete doc.type;
// Create the document.
collection.createDocument(collection.getSelfLink(), doc, function(err, result) {
if(err) throw err;
// Return the resulting document back as the response.
response.setBody(result);
});
}

Django + PostgreSQL: Synchronize database with external source

I'm looking for a way to synchronize some tables in database with an external source. I would check this external source every couple of hours for changes and if there are any, I would update my database.
My question is, if anybody knows about an existing app, that accepts some kind of data structure (a python dict) and translates this into database entries?
Here is an example: Lets say I have the following models:
class Language(models.Model):
tag = models.CharFieldmax_length=10)
name = models.CharField(max_length=50)
class Unit(models.Model):
label = models.CharField(max_length=10)
name = models.CharField(max_length=200)
class UnitTranslations(models.Model):
unit = models.ForeignKey(Unit)
language = models.ForeignKey(Language)
name = models.CharField(max_length=200)
So I could have corresponding data, that looks like this:
data = [
{
"label": "AB",
"name": "some random name",
"translations": [
{
"name": "some random name in german",
"language": {
"tag": "de",
"name": "german"
}
},
{
"name": "some random name in spanish",
"language": {
"tag": "es",
"name": "spanish"
}
},
]
},
{
"label": "OR",
"name": "some other random name",
"translations": [
{
"name": "some other random name in german",
"language": {
"tag": "de",
"name": "german"
}
},
{
"name": "some other random name in spanish",
"language": {
"tag": "es",
"name": "spanish"
}
},
]
},
]
So, I would like to take this structure (plus some meta informations on what the actuals models are, what attributes can be seen as IDs and so on), and have my program automatically update the necessary tables.
To finish my example, those are in short the main steps that need to be performed:
Is already a Unit with label "AB"? (otherwise create it)
Does it have the name "some random name"? (otherwise change it)
Do we have the languages german and spanish? (otherwise create them)
Do we have translations for german and spanish? (otherwise create them)
Are these translations "some random name in german" and "some random name in spanish" respectively? (otherwise change them)
But of course, the structure can be more complex. That's why I would be thankful for every library or app (or idea) that makes my life a bit easier.

Flattening af collection to properties on document in RavenDB

I have some documents in RavenDB with a collection of attributes, which I would like to flatten using an index.
The document structure is something similar to:
{
"Id": "test/1",
"Name": "Some name",
"Attributes": [
{ "Key": "FirstAttr", "Value": "FirstValue" },
{ "Key": "SecondAttr", "Value": "SecondValue" }
]}
My desired output is:
{
"Id": "test/1",
"Name": "Some name",
"FirstAttr": "FirstValue",
"SecondAttr": "SecondValue"
}
Is this possible in RavenDB?
Thanks a bunch!
Ok - answering my own question so others can benefit:
The CreateField method seems to be what I need in the map part in my index:
from t in docs.Test
select new {
t.Id,
t.Name,
_ = t.Attributes.Select(x => this.CreateField(x.Key, x.Value, true, true))
}
Can you do this during the map-reduce?
Map = docs =>
from doc in docs
select new {
Id = doc.Id,
Name = doc.Name,
FirstAttr = (doc.Attributes.ContainsKey("FirstAttr") ? doc.Attributes["FirstAttr"] : null,
SecondAttr = (doc.Attributes.ContainsKey("SecondAttr") ? doc.Attributes["SecondAttr"] : null
};