nodejs gremlin update if exist or else create - node.js

I am using nodejs gremlin against AWS neptune, the requirement is to update properties if vertice exist, or else, create a new vertice, i tried below
g.V().has('event','id','1').
fold().
coalesce(unfold(),
addV('event').property('id','1'))
but I got 'unfold is not defined' error, how do I resolve this?

You probably just need to import unfold() properly. Some common imports for working with Gremlin can be found here but in your case I think you just need to do:
const __ = gremlin.process.statics
and then refer to unfold() as __.unfold() - or just import unfold() as a function explicitly to use it as you were using it.

Related

Executing UDF ( User Defined function ) containing a Node module in Cosmos Db

I have created a UDF function to process some content based on dates in Azure cosmos database. The function looks like below
function userDefinedFunction(array,dateString){
var moment = require('moment');
const startDate = moment(dateString);
const endDate = moment(dateString).add(1,'days');
// filter the array by the dates and return a value
}
When the above UDF is used inside a query the following error message is thrown .
Encountered exception while executing Javascript. Exception = ReferenceError: 'require' is not defined
This error is seemed to be an error orginating from incorrect import of the moment node module.
i have already tried checking on the microsoft offcial docs about the UDFs and using of node module inside UDF.
I tried surfing through the internet about this issue, but both the methods did not provide me with satisfactory answer.
so i would like to know how to import a node module and use it inside an UDF function . Thanks a lot in advance .
Importing modules is not supported for any of the service-side features including stored procedures, triggers and user-defined functions.
This is not currently documented. Will ask for this to be updated.

Issue NestJS with oracle TypeORM

I'm trying to connect my NestJs Project with a Oracle db and I'm using TypeORM and the status of connection is ok but I don't know how I can connect with a function. This function is into of a package and at the same time this package is into of a schema. The structure is like:
mySchema:
--------->myPackage:
-------------------->myFunction(id)
In the NestJS code I'm define this import in the AppModule file:
When I try to use the entity I don't know what method can I use to connect with my function. With the ESLint I get the next methods:
I hope to be clear and thanks for all!
In you last picture you’re trying to make a request to the database and as you can see, when you mentioned the testRepository and dots(.) now you have to tell him what you want to do in your database and in the suggested list you have all the possible possibilities.
So if you want to get or fetch data from you database, you will use testRepository.find() this will give you everything in that particular entity. To do that, you have to do something like below, before that you code has something that I have never seen in Nest, (public); if it does exist but I won’t use that in my Example since I don’t know it in Nest and also; you have started writing without (return) I don’t know how you’re expecting to return what you will get from your database.
Here is my example:
in your controller:
#Get() AnyThing(): Promise<TestEntity[]> {return this.DaobscsService.whatEver(); }
And in your service:
#InjectRepository(TestEntity) private readonlytestRepository: Repository<TestEntity>, ) {}
async whatEver(): Promise<TestEntity[]> {return await this.testRepository.find();}
What ever name you gonna use instead (whatEver()) in the service that have used, remember to use the same name in your controller pointing to service (this.Boa...Service.(The name here) OOP system’s you know it I hope
This example is to get or fetch so if you don’t have any thing in your database then you will get nothing! if that’s not what u want then command with a full version of what exactly is your issue, what u expected and code from controller, service, and module.

MYSQL X DEV API Update method not working

I could not find a good template for the update method for the xdevapi library and thought maybe some one could help me out with getting this to work.
acts_table
.update()
.set('account_status', 'new account status')
.where('customer_number like :customer_number && original_account_number like :original_account_number')
.bind('01234588456')
.bind('12156464645')
.execute()
I think its just a formatting issue, but with no real examples in the XDEVAPI Documentation for update for Javascript I'm kind of at a lost. Please help. The error I get is Cannot Read property 'toArray' of undefined.
It was formatting, in the bind method I forgot to put the fields we were binding so the answer is this:
acts_table
.update()
.set('account_status', 'new account status')
.where('customer_number like :customer_number && original_account_number like :original_account_number')
.bind('customer_number','01234588456')
.bind('original_account_number', '12156464645')
.execute()

group by in Flask-MongoAlchemy

i stared new project with flask web-framework with mongoDB. i also used database and access data using Flask-MongoAlchemy. i tried work on different query like .all(), .filter_by(), .get() its work nice. but problem is that how to use aggregate funcation in Flask-MongoAlchemy ? for example i want to use group_by.
i tried following but its still not working.
db.User.qroup_by(name)
its gives following error
'BaseQuery' object has no attribute 'group_by'

Retrieve all records of model (ORM2, nodejs)

Using the ORM2 module in Node.js, after creating a connection and checking that works, I can't find a way to retrieve all the records of a model, like the ActiveRecord's way Model.all . I'm new to ORM2 and it seems pretty obvious, but I don't have a clue...
I think this does it:
var Blah = db.models.blah;
Blah.all(function(err, blahs){
})
Looking at the code Model.js which defines the methods for the Model (Blah above) has the following line:
model.all = model.find;
So I assume Blah.find() would work as well. The methods used in the model instances are defined in the file Instance.js. The documentation isn't super, but I have been happy with the project so far, and likely can help out if you have questions

Resources