Take an object:
let keyObject = {"Dog": "red", "Cat": "blue", "Parrot": "yellow"}
I am able to use Object.keys(keyObject) function to access the keys, but get an error when using Object.values(keyObject)
Error: Object.values is not a function
Does MarkLogic not support this function yet?
Object.values() is a new function that will be included in ES 2017.
It is available in ML 10, thanks to the upgrade of the V8 engine: https://www.marklogic.com/blog/v8-engine-upgrade-in-marklogic-10/.
Related
For library arangodb-spring-data, version 3.2.3, is there any possibility to query for GEO_INTERSECTS functionality using the java api provided by the driver?
Currently I am using an AQL query in my code:
LET areaLiteral = GEO_POLYGON(...)
FOR doc IN MyDocuments
FILTER GEO_INTERSECTS(areaLiteral, doc.geometry)
LIMIT 5 RETURN doc
So far in the official documentation couldn't find anything related to GEO_INTERSECTS, also in this example: https://github.com/arangodb/spring-data-demo#geospatial-queries
I have checked the source code of the driver, but didn't find anything related to keyword "INTERSECTS" which would construct this query behind the scenes.
It is not yet supported, the only supported geospatial queries are Near and Within:
https://www.arangodb.com/docs/3.6/drivers/spring-data-reference-repositories-queries-derived-queries.html#geospatial-queries
I upgraded CosmosDB Node.js SDK from 2.1.5 to 3.5.2 and the following code is no longer working.
client.items.query(myQuery, { partitionKey: "MyPartitionKey" }).toArray()
I changed the code to the following but it still does not transpile (typescript) and apparently the cause is that FeedOptions no longer contains partitionKey property!
client.items.query(myQuery,{ partitionKey: "MyPartitionKey" }).fetchAll()
I looked it up in the internet but could not find an up to date example.
Any idea how to fix this?
Turns out in v3 of the sdk there is no need to explicitly assign partitionkey value. If partitionkey engages in where clause, it will automatically be regarded.
githib issue reference
I can't find any up-to-date example from MS or github source code which is really challenging.
There is no any partitionkey property in FeedOptions class in the cosmos db node sdk v3 any more.After my deep research on the github source code of FeedOptions,i found that it extends another interface SharedOptions:
And it contains initialHeaders property so that i'm supposed that we could set partition key value following the REST API Header Lists.
Anyway,please refer to my working code:
const feedOptions = {
initialHeaders: {"x-ms-documentdb-partitionkey": '["a"]'}
};
const queryIterator = await container.items.query(querySpec,feedOptions);
while (queryIterator.hasMoreResults()) {
console.log(await queryIterator.fetchNext());
}
Surely,you could replace it with .fetchAll() method.
using:
node.js - version 8.0.0
neo4j-driver: 1.3.0
neo4j database: community edition, version: 3.2.0
i am running a cypher (not important what exactly is the cypher) and getting back a result.
after parsing the result using the follwing code:
result.records[0].get('instanceStock').properties
i am getting the following json:
{
"quantity":{
"low":10,
"high":0
}
}
the value 10 is the correct one which actually reside inside the db.
what is the meaning of the "low" and "high" properties?
why the correct answer reside inside the "low" property?
This has to do with how 64bit integers are handled in JS. More explanation here :
https://github.com/neo4j/neo4j-javascript-driver/tree/ad0317a675d50443ca97f157f119957354b74ae3#numbers-and-the-integer-type
Maybe the question does not apply to dynamoDB due to it not being Relational Db.
However, I'm looking for a good object mapper which can be used in nodejs and aws sdk to map existing model classes to dynamoDB tables. Does anyone have experience with this issue/question, or have you used such a module/library?
If you are looking for schema:
https://github.com/clarkie/dynogels (well supported forked from vogels which has been abandoned)
https://github.com/automategreen/dynamoose (inspired by Mongoose)
If you are looking for something to throw javascript objects (even circular graphs) to:
https://github.com/aaaristo/dyngodb (alpha)
https://github.com/aaaristo/angular-gson-express-dyngodb
dyngodb has experimental support for full-text search, and transactions too.
Both are based on aws-sdk.
Also worth considering is simple marshallers, which just translate between the dynamoDB format and regular js objects or JSON.
DynamoDb-Data-Types
https://github.com/kayomarz/dynamodb-data-types
https://www.npmjs.com/package/dynamodb-data-types
"This utility helps represent AWS DynamoDb data types. It maps (marshalls) JavaScript data into the format required by DynamoDb."
dynamoDb-marshaler
https://github.com/CascadeEnergy/dynamoDb-marshaler
https://www.npmjs.com/package/dynamodb-marshaler
"Translates sane javascript objects (and JSON) into DynamoDb format and vice versa." [does not support B type.]
Update 2016-06:
Just discovered that the AWS SDK now does this for you. Their documentation is only partially converted so I guess this is a recent addition. Read about it here.
But these marshallers are still useful because there are circumstances where you can't use the new document client, eg. when processing a dynamoDB stream.
You could also try: https://dynamoosejs.com/. It is inspired by mongoose again.
If you are using Typescript, dynamo-easy might be a good option. Just add some decorators to your model and start using it.
import { Model, PartitionKey, DynamoStore } from '#shiftcoders/dynamo-easy'
#Model()
export class Person {
#PartitionKey()
id: string
name: string
yearOfBirth: number
}
const personStore = new DynamoStore(Person)
personStore
.scan()
.whereAttribute('yearOfBirth').equals(1958)
.exec()
.then(res => console.log('ALL items with yearOfBirth == 1958', res))
It uses the AWS DynamoDB sdk but takes care of the mapping between JS and DynamoDB types and provides a simple to use fluent API.
full disclosure: I am one of the authors of this library
After looking over all the posts I landed on https://github.com/awspilot/dynamodb-oop
It doesn't hide the API but instead just wraps it in a nice, fluent way with promises even and you inject your version of the aws-sdk. It's similar to dynamodb-data-types but also wraps the methods too (not just the data types).
Extra bonus, the same author has https://github.com/awspilot/dynamodb-sql Didn't use the sql wrapper but I can see how some people may prefer that.
Dynamoose is obviously inspired by mongoose and is a good choice if you have a well-defined schema and/or want to be abstracted away from the DynamoDB details.
Have you seen dynasaur? It seems to be the type of thing you're looking for, but I have not used it myself. There's also dynamodb-data-types which is not an ORM, but makes it easy to convert to/from standard JavaScript objects.
I'm really new to arangodb (and graph databases). I'm trying to use the sortest_path function:
FOR p in SHORTEST_PATH(imdb_vertices, imdb_edges, "imdb_vertices/349","imdb_vertices/1931", "any", { paths: true})
RETURN p
But the shells returns:
usage of unknown function 'SHORTEST_PATH()'
In the docs I can't find a working example of use of this function.
First of all, the SHORTEST_PATH function has been added in ArangoDB 1.4.11. Can you make sure you are using an ArangoDB server version as least as high as that?
Second, a few examples for SHORTEST_PATH should be here:
https://www.arangodb.org/manuals/1/Aql.html#AqlFunctionsGraph